home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 6 / CU Amiga Magazine's Super CD-ROM 06 (1996)(EMAP Images)(GB)(Track 1 of 4)[!][issue 1997-01].iso / cucd / prog / gnu-c / src / gcc-2.7.0-amiga / final.c < prev    next >
C/C++ Source or Header  |  1995-08-24  |  84KB  |  3,142 lines

  1. /* Convert RTL to assembler code and output it, for GNU compiler.
  2.    Copyright (C) 1987, 88, 89, 92, 93, 94, 1995 Free Software Foundation, Inc.
  3.  
  4. This file is part of GNU CC.
  5.  
  6. GNU CC is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2, or (at your option)
  9. any later version.
  10.  
  11. GNU CC is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with GNU CC; see the file COPYING.  If not, write to
  18. the Free Software Foundation, 59 Temple Place - Suite 330,
  19. Boston, MA 02111-1307, USA.  */
  20.  
  21.  
  22. /* This is the final pass of the compiler.
  23.    It looks at the rtl code for a function and outputs assembler code.
  24.  
  25.    Call `final_start_function' to output the assembler code for function entry,
  26.    `final' to output assembler code for some RTL code,
  27.    `final_end_function' to output assembler code for function exit.
  28.    If a function is compiled in several pieces, each piece is
  29.    output separately with `final'.
  30.  
  31.    Some optimizations are also done at this level.
  32.    Move instructions that were made unnecessary by good register allocation
  33.    are detected and omitted from the output.  (Though most of these
  34.    are removed by the last jump pass.)
  35.  
  36.    Instructions to set the condition codes are omitted when it can be
  37.    seen that the condition codes already had the desired values.
  38.  
  39.    In some cases it is sufficient if the inherited condition codes
  40.    have related values, but this may require the following insn
  41.    (the one that tests the condition codes) to be modified.
  42.  
  43.    The code for the function prologue and epilogue are generated
  44.    directly as assembler code by the macros FUNCTION_PROLOGUE and
  45.    FUNCTION_EPILOGUE.  Those instructions never exist as rtl.  */
  46.  
  47. #include "config.h"
  48. #ifdef __STDC__
  49. #include <stdarg.h>
  50. #else
  51. #include <varargs.h>
  52. #endif
  53. #include <stdio.h>
  54. #include <ctype.h>
  55.  
  56. #include "tree.h"
  57. #include "rtl.h"
  58. #include "regs.h"
  59. #include "insn-config.h"
  60. #include "insn-flags.h"
  61. #include "insn-attr.h"
  62. #include "insn-codes.h"
  63. #include "recog.h"
  64. #include "conditions.h"
  65. #include "flags.h"
  66. #include "real.h"
  67. #include "hard-reg-set.h"
  68. #include "defaults.h"
  69. #include "output.h"
  70.  
  71. /* Get N_SLINE and N_SOL from stab.h if we can expect the file to exist.  */
  72. #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
  73. #if defined (USG) || defined (NO_STAB_H)
  74. #include "gstab.h"  /* If doing DBX on sysV, use our own stab.h.  */
  75. #else
  76. #include <stab.h>  /* On BSD, use the system's stab.h.  */
  77. #endif /* not USG */
  78. #endif /* DBX_DEBUGGING_INFO || XCOFF_DEBUGGING_INFO */
  79.  
  80. #ifdef XCOFF_DEBUGGING_INFO
  81. #include "xcoffout.h"
  82. #endif
  83.  
  84. /* .stabd code for line number.  */
  85. #ifndef N_SLINE
  86. #define    N_SLINE    0x44
  87. #endif
  88.  
  89. /* .stabs code for included file name.  */
  90. #ifndef N_SOL
  91. #define    N_SOL 0x84
  92. #endif
  93.  
  94. #ifndef INT_TYPE_SIZE
  95. #define INT_TYPE_SIZE BITS_PER_WORD
  96. #endif
  97.  
  98. /* If we aren't using cc0, CC_STATUS_INIT shouldn't exist.  So define a
  99.    null default for it to save conditionalization later.  */
  100. #ifndef CC_STATUS_INIT
  101. #define CC_STATUS_INIT
  102. #endif
  103.  
  104. /* How to start an assembler comment.  */
  105. #ifndef ASM_COMMENT_START
  106. #define ASM_COMMENT_START ";#"
  107. #endif
  108.  
  109. /* Is the given character a logical line separator for the assembler?  */
  110. #ifndef IS_ASM_LOGICAL_LINE_SEPARATOR
  111. #define IS_ASM_LOGICAL_LINE_SEPARATOR(C) ((C) == ';')
  112. #endif
  113.  
  114. /* Nonzero means this function is a leaf function, with no function calls. 
  115.    This variable exists to be examined in FUNCTION_PROLOGUE
  116.    and FUNCTION_EPILOGUE.  Always zero, unless set by some action.  */
  117. int leaf_function;
  118.  
  119. /* Last insn processed by final_scan_insn.  */
  120. static rtx debug_insn = 0;
  121.  
  122. /* Line number of last NOTE.  */
  123. static int last_linenum;
  124.  
  125. /* Highest line number in current block.  */
  126. static int high_block_linenum;
  127.  
  128. /* Likewise for function.  */
  129. static int high_function_linenum;
  130.  
  131. /* Filename of last NOTE.  */
  132. static char *last_filename;
  133.  
  134. /* Number of basic blocks seen so far;
  135.    used if profile_block_flag is set.  */
  136. static int count_basic_blocks;
  137.  
  138. /* Nonzero while outputting an `asm' with operands.
  139.    This means that inconsistencies are the user's fault, so don't abort.
  140.    The precise value is the insn being output, to pass to error_for_asm.  */
  141. static rtx this_is_asm_operands;
  142.  
  143. /* Number of operands of this insn, for an `asm' with operands.  */
  144. static int insn_noperands;
  145.  
  146. /* Compare optimization flag.  */
  147.  
  148. static rtx last_ignored_compare = 0;
  149.  
  150. /* Flag indicating this insn is the start of a new basic block.  */
  151.  
  152. static int new_block = 1;
  153.  
  154. /* All the symbol-blocks (levels of scoping) in the compilation
  155.    are assigned sequence numbers in order of appearance of the
  156.    beginnings of the symbol-blocks.  Both final and dbxout do this,
  157.    and assume that they will both give the same number to each block.
  158.    Final uses these sequence numbers to generate assembler label names
  159.    LBBnnn and LBEnnn for the beginning and end of the symbol-block.
  160.    Dbxout uses the sequence numbers to generate references to the same labels
  161.    from the dbx debugging information.
  162.  
  163.    Sdb records this level at the beginning of each function,
  164.    in order to find the current level when recursing down declarations.
  165.    It outputs the block beginning and endings
  166.    at the point in the asm file where the blocks would begin and end.  */
  167.  
  168. int next_block_index;
  169.  
  170. /* Assign a unique number to each insn that is output.
  171.    This can be used to generate unique local labels.  */
  172.  
  173. static int insn_counter = 0;
  174.  
  175. #ifdef HAVE_cc0
  176. /* This variable contains machine-dependent flags (defined in tm.h)
  177.    set and examined by output routines
  178.    that describe how to interpret the condition codes properly.  */
  179.  
  180. CC_STATUS cc_status;
  181.  
  182. /* During output of an insn, this contains a copy of cc_status
  183.    from before the insn.  */
  184.  
  185. CC_STATUS cc_prev_status;
  186. #endif
  187.  
  188. /* Indexed by hardware reg number, is 1 if that register is ever
  189.    used in the current function.
  190.  
  191.    In life_analysis, or in stupid_life_analysis, this is set
  192.    up to record the hard regs used explicitly.  Reload adds
  193.    in the hard regs used for holding pseudo regs.  Final uses
  194.    it to generate the code in the function prologue and epilogue
  195.    to save and restore registers as needed.  */
  196.  
  197. char regs_ever_live[FIRST_PSEUDO_REGISTER];
  198.  
  199. /* Nonzero means current function must be given a frame pointer.
  200.    Set in stmt.c if anything is allocated on the stack there.
  201.    Set in reload1.c if anything is allocated on the stack there.  */
  202.  
  203. int frame_pointer_needed;
  204.  
  205. /* Assign unique numbers to labels generated for profiling.  */
  206.  
  207. int profile_label_no;
  208.  
  209. /* Length so far allocated in PENDING_BLOCKS.  */
  210.  
  211. static int max_block_depth;
  212.  
  213. /* Stack of sequence numbers of symbol-blocks of which we have seen the
  214.    beginning but not yet the end.  Sequence numbers are assigned at
  215.    the beginning; this stack allows us to find the sequence number
  216.    of a block that is ending.  */
  217.  
  218. static int *pending_blocks;
  219.  
  220. /* Number of elements currently in use in PENDING_BLOCKS.  */
  221.  
  222. static int block_depth;
  223.  
  224. /* Nonzero if have enabled APP processing of our assembler output.  */
  225.  
  226. static int app_on;
  227.  
  228. /* If we are outputting an insn sequence, this contains the sequence rtx.
  229.    Zero otherwise.  */
  230.  
  231. rtx final_sequence;
  232.  
  233. #ifdef ASSEMBLER_DIALECT
  234.  
  235. /* Number of the assembler dialect to use, starting at 0.  */
  236. static int dialect_number;
  237. #endif
  238.  
  239. /* Indexed by line number, nonzero if there is a note for that line.  */
  240.  
  241. static char *line_note_exists;
  242.  
  243. /* Linked list to hold line numbers for each basic block.  */
  244.  
  245. struct bb_list {
  246.   struct bb_list *next;        /* pointer to next basic block */
  247.   int line_num;            /* line number */
  248.   int file_label_num;        /* LPBC<n> label # for stored filename */
  249.   int func_label_num;        /* LPBC<n> label # for stored function name */
  250. };
  251.  
  252. static struct bb_list *bb_head    = 0;        /* Head of basic block list */
  253. static struct bb_list **bb_tail = &bb_head;    /* Ptr to store next bb ptr */
  254. static int bb_file_label_num    = -1;        /* Current label # for file */
  255. static int bb_func_label_num    = -1;        /* Current label # for func */
  256.  
  257. /* Linked list to hold the strings for each file and function name output.  */
  258.  
  259. struct bb_str {
  260.   struct bb_str *next;        /* pointer to next string */
  261.   char *string;            /* string */
  262.   int label_num;        /* label number */
  263.   int length;            /* string length */
  264. };
  265.  
  266. extern rtx peephole        PROTO((rtx));
  267.  
  268. static struct bb_str *sbb_head    = 0;        /* Head of string list.  */
  269. static struct bb_str **sbb_tail    = &sbb_head;    /* Ptr to store next bb str */
  270. static int sbb_label_num    = 0;        /* Last label used */
  271.  
  272. static int asm_insn_count    PROTO((rtx));
  273. static void profile_function    PROTO((FILE *));
  274. static void profile_after_prologue PROTO((FILE *));
  275. static void add_bb        PROTO((FILE *));
  276. static int add_bb_string    PROTO((char *, int));
  277. static void output_source_line    PROTO((FILE *, rtx));
  278. static rtx walk_alter_subreg    PROTO((rtx));
  279. static int alter_cond        PROTO((rtx));
  280. static void output_asm_name    PROTO((void));
  281. static void output_operand    PROTO((rtx, int));
  282. static void leaf_renumber_regs    PROTO((rtx));
  283.  
  284. extern char *getpwd ();
  285.  
  286. /* Initialize data in final at the beginning of a compilation.  */
  287.  
  288. void
  289. init_final (filename)
  290.      char *filename;
  291. {
  292.   next_block_index = 2;
  293.   app_on = 0;
  294.   max_block_depth = 20;
  295.   pending_blocks = (int *) xmalloc (20 * sizeof *pending_blocks);
  296.   final_sequence = 0;
  297.  
  298. #ifdef ASSEMBLER_DIALECT
  299.   dialect_number = ASSEMBLER_DIALECT;
  300. #endif
  301. }
  302.  
  303. /* Called at end of source file,
  304.    to output the block-profiling table for this entire compilation.  */
  305.  
  306. void
  307. end_final (filename)
  308.      char *filename;
  309. {
  310.   int i;
  311.  
  312.   if (profile_block_flag)
  313.     {
  314.       char name[20];
  315.       int align = exact_log2 (BIGGEST_ALIGNMENT / BITS_PER_UNIT);
  316.       int size = (POINTER_SIZE / BITS_PER_UNIT) * count_basic_blocks;
  317.       int rounded = size;
  318.       struct bb_list *ptr;
  319.       struct bb_str *sptr;
  320.  
  321.       rounded += (BIGGEST_ALIGNMENT / BITS_PER_UNIT) - 1;
  322.       rounded = (rounded / (BIGGEST_ALIGNMENT / BITS_PER_UNIT)
  323.          * (BIGGEST_ALIGNMENT / BITS_PER_UNIT));
  324.  
  325.       data_section ();
  326.  
  327.       /* Output the main header, of 10 words:
  328.      0:  1 if this file's initialized, else 0.
  329.      1:  address of file name (LPBX1).
  330.      2:  address of table of counts (LPBX2).
  331.      3:  number of counts in the table.
  332.      4:  always 0, for compatibility with Sun.
  333.  
  334.          The following are GNU extensions:
  335.  
  336.      5:  address of table of start addrs of basic blocks (LPBX3).
  337.      6:  Number of bytes in this header.
  338.      7:  address of table of function names (LPBX4).
  339.      8:  address of table of line numbers (LPBX5) or 0.
  340.      9:  address of table of file names (LPBX6) or 0.  */
  341.  
  342.       ASM_OUTPUT_ALIGN (asm_out_file, align);
  343.  
  344.       ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "LPBX", 0);
  345.       /* zero word */
  346.       assemble_integer (const0_rtx, UNITS_PER_WORD, 1);
  347.  
  348.       /* address of filename */
  349.       ASM_GENERATE_INTERNAL_LABEL (name, "LPBX", 1);
  350.       assemble_integer (gen_rtx (SYMBOL_REF, Pmode, name), UNITS_PER_WORD, 1);
  351.  
  352.       /* address of count table */
  353.       ASM_GENERATE_INTERNAL_LABEL (name, "LPBX", 2);
  354.       assemble_integer (gen_rtx (SYMBOL_REF, Pmode, name), UNITS_PER_WORD, 1);
  355.  
  356.       /* count of the # of basic blocks */
  357.       assemble_integer (GEN_INT (count_basic_blocks), UNITS_PER_WORD, 1);
  358.  
  359.       /* zero word (link field) */
  360.       assemble_integer (const0_rtx, UNITS_PER_WORD, 1);
  361.  
  362.       /* address of basic block start address table */
  363.       ASM_GENERATE_INTERNAL_LABEL (name, "LPBX", 3);
  364.       assemble_integer (gen_rtx (SYMBOL_REF, Pmode, name), UNITS_PER_WORD, 1);
  365.  
  366.       /* byte count for extended structure.  */
  367.       assemble_integer (GEN_INT (10 * UNITS_PER_WORD), UNITS_PER_WORD, 1);
  368.  
  369.       /* address of function name table */
  370.       ASM_GENERATE_INTERNAL_LABEL (name, "LPBX", 4);
  371.       assemble_integer (gen_rtx (SYMBOL_REF, Pmode, name), UNITS_PER_WORD, 1);
  372.  
  373.       /* address of line number and filename tables if debugging.  */
  374.       if (write_symbols != NO_DEBUG)
  375.     {
  376.       ASM_GENERATE_INTERNAL_LABEL (name, "LPBX", 5);
  377.       assemble_integer (gen_rtx (SYMBOL_REF, Pmode, name), UNITS_PER_WORD, 1);
  378.       ASM_GENERATE_INTERNAL_LABEL (name, "LPBX", 6);
  379.       assemble_integer (gen_rtx (SYMBOL_REF, Pmode, name), UNITS_PER_WORD, 1);
  380.     }
  381.       else
  382.     {
  383.       assemble_integer (const0_rtx, UNITS_PER_WORD, 1);
  384.       assemble_integer (const0_rtx, UNITS_PER_WORD, 1);
  385.     }
  386.  
  387.       /* Output the file name changing the suffix to .d for Sun tcov
  388.      compatibility.  */
  389.       ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "LPBX", 1);
  390.       {
  391.     char *cwd = getpwd ();
  392.     int len = strlen (filename) + strlen (cwd) + 1;
  393.     char *data_file = (char *) alloca (len + 4);
  394.  
  395.     strcpy (data_file, cwd);
  396.     strcat (data_file, "/");
  397.     strcat (data_file, filename);
  398.     strip_off_ending (data_file, len);
  399.     strcat (data_file, ".d");
  400.     assemble_string (data_file, strlen (data_file) + 1);
  401.       }
  402.  
  403.       /* Make space for the table of counts.  */
  404.       if (flag_no_common || size == 0)
  405.     {
  406.       /* Realign data section.  */
  407.       ASM_OUTPUT_ALIGN (asm_out_file, align);
  408.       ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "LPBX", 2);
  409.       if (size != 0)
  410.         assemble_zeros (size);
  411.     }
  412.       else
  413.     {
  414.       ASM_GENERATE_INTERNAL_LABEL (name, "LPBX", 2);
  415. #ifdef ASM_OUTPUT_SHARED_LOCAL
  416.       if (flag_shared_data)
  417.         ASM_OUTPUT_SHARED_LOCAL (asm_out_file, name, size, rounded);
  418.       else
  419. #endif
  420. #ifdef ASM_OUTPUT_ALIGNED_LOCAL
  421.         ASM_OUTPUT_ALIGNED_LOCAL (asm_out_file, name, size,
  422.                       BIGGEST_ALIGNMENT);
  423. #else
  424.         ASM_OUTPUT_LOCAL (asm_out_file, name, size, rounded);
  425. #endif
  426.     }
  427.  
  428.       /* Output any basic block strings */
  429.       readonly_data_section ();
  430.       if (sbb_head)
  431.     {
  432.       ASM_OUTPUT_ALIGN (asm_out_file, align);
  433.       for (sptr = sbb_head; sptr != 0; sptr = sptr->next)
  434.         {
  435.           ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "LPBC", sptr->label_num);
  436.           assemble_string (sptr->string, sptr->length);
  437.         }
  438.     }
  439.  
  440.       /* Output the table of addresses.  */
  441.       /* Realign in new section */
  442.       ASM_OUTPUT_ALIGN (asm_out_file, align);
  443.       ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "LPBX", 3);
  444.       for (i = 0; i < count_basic_blocks; i++)
  445.     {
  446.       ASM_GENERATE_INTERNAL_LABEL (name, "LPB", i);
  447.       assemble_integer (gen_rtx (SYMBOL_REF, Pmode, name),
  448.                 UNITS_PER_WORD, 1);
  449.     }
  450.  
  451.       /* Output the table of function names.  */
  452.       ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "LPBX", 4);
  453.       for ((ptr = bb_head), (i = 0); ptr != 0; (ptr = ptr->next), i++)
  454.     {
  455.       if (ptr->func_label_num >= 0)
  456.         {
  457.           ASM_GENERATE_INTERNAL_LABEL (name, "LPBC", ptr->func_label_num);
  458.           assemble_integer (gen_rtx (SYMBOL_REF, Pmode, name),
  459.                 UNITS_PER_WORD, 1);
  460.         }
  461.       else
  462.         assemble_integer (const0_rtx, UNITS_PER_WORD, 1);
  463.     }
  464.  
  465.       for ( ; i < count_basic_blocks; i++)
  466.     assemble_integer (const0_rtx, UNITS_PER_WORD, 1);
  467.  
  468.       if (write_symbols != NO_DEBUG)
  469.     {
  470.       /* Output the table of line numbers.  */
  471.       ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "LPBX", 5);
  472.       for ((ptr = bb_head), (i = 0); ptr != 0; (ptr = ptr->next), i++)
  473.         assemble_integer (GEN_INT (ptr->line_num), UNITS_PER_WORD, 1);
  474.  
  475.       for ( ; i < count_basic_blocks; i++)
  476.         assemble_integer (const0_rtx, UNITS_PER_WORD, 1);
  477.  
  478.       /* Output the table of file names.  */
  479.       ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "LPBX", 6);
  480.       for ((ptr = bb_head), (i = 0); ptr != 0; (ptr = ptr->next), i++)
  481.         {
  482.           if (ptr->file_label_num >= 0)
  483.         {
  484.           ASM_GENERATE_INTERNAL_LABEL (name, "LPBC", ptr->file_label_num);
  485.           assemble_integer (gen_rtx (SYMBOL_REF, Pmode, name),
  486.                     UNITS_PER_WORD, 1);
  487.         }
  488.           else
  489.         assemble_integer (const0_rtx, UNITS_PER_WORD, 1);
  490.         }
  491.  
  492.       for ( ; i < count_basic_blocks; i++)
  493.         assemble_integer (const0_rtx, UNITS_PER_WORD, 1);
  494.     }
  495.  
  496.       /* End with the address of the table of addresses,
  497.      so we can find it easily, as the last word in the file's text.  */
  498.       ASM_GENERATE_INTERNAL_LABEL (name, "LPBX", 3);
  499.       assemble_integer (gen_rtx (SYMBOL_REF, Pmode, name), UNITS_PER_WORD, 1);
  500.     }
  501. }
  502.  
  503. /* Enable APP processing of subsequent output.
  504.    Used before the output from an `asm' statement.  */
  505.  
  506. void
  507. app_enable ()
  508. {
  509.   if (! app_on)
  510.     {
  511.       fprintf (asm_out_file, ASM_APP_ON);
  512.       app_on = 1;
  513.     }
  514. }
  515.  
  516. /* Disable APP processing of subsequent output.
  517.    Called from varasm.c before most kinds of output.  */
  518.  
  519. void
  520. app_disable ()
  521. {
  522.   if (app_on)
  523.     {
  524.       fprintf (asm_out_file, ASM_APP_OFF);
  525.       app_on = 0;
  526.     }
  527. }
  528.  
  529. /* Return the number of slots filled in the current 
  530.    delayed branch sequence (we don't count the insn needing the
  531.    delay slot).   Zero if not in a delayed branch sequence.  */
  532.  
  533. #ifdef DELAY_SLOTS
  534. int
  535. dbr_sequence_length ()
  536. {
  537.   if (final_sequence != 0)
  538.     return XVECLEN (final_sequence, 0) - 1;
  539.   else
  540.     return 0;
  541. }
  542. #endif
  543.  
  544. /* The next two pages contain routines used to compute the length of an insn
  545.    and to shorten branches.  */
  546.  
  547. /* Arrays for insn lengths, and addresses.  The latter is referenced by
  548.    `insn_current_length'.  */
  549.  
  550. static short *insn_lengths;
  551. int *insn_addresses;
  552.  
  553. /* Address of insn being processed.  Used by `insn_current_length'.  */
  554. int insn_current_address;
  555.  
  556. /* Indicate that branch shortening hasn't yet been done.  */
  557.  
  558. void
  559. init_insn_lengths ()
  560. {
  561.   insn_lengths = 0;
  562. }
  563.  
  564. /* Obtain the current length of an insn.  If branch shortening has been done,
  565.    get its actual length.  Otherwise, get its maximum length.  */
  566.  
  567. int
  568. get_attr_length (insn)
  569.      rtx insn;
  570. {
  571. #ifdef HAVE_ATTR_length
  572.   rtx body;
  573.   int i;
  574.   int length = 0;
  575.  
  576.   if (insn_lengths)
  577.     return insn_lengths[INSN_UID (insn)];
  578.   else
  579.     switch (GET_CODE (insn))
  580.       {
  581.       case NOTE:
  582.       case BARRIER:
  583.       case CODE_LABEL:
  584.     return 0;
  585.  
  586.       case CALL_INSN:
  587.     length = insn_default_length (insn);
  588.     break;
  589.  
  590.       case JUMP_INSN:
  591.     body = PATTERN (insn);
  592.         if (GET_CODE (body) == ADDR_VEC || GET_CODE (body) == ADDR_DIFF_VEC)
  593.       {
  594.         /* This only takes room if jump tables go into the text section.  */
  595. #if !defined(READONLY_DATA_SECTION) || defined(JUMP_TABLES_IN_TEXT_SECTION)
  596.         length = (XVECLEN (body, GET_CODE (body) == ADDR_DIFF_VEC)
  597.               * GET_MODE_SIZE (GET_MODE (body)));
  598.  
  599.         /* Be pessimistic and assume worst-case alignment.  */
  600.         length += (GET_MODE_SIZE (GET_MODE (body)) - 1);
  601. #else
  602.         return 0;
  603. #endif
  604.       }
  605.     else
  606.       length = insn_default_length (insn);
  607.     break;
  608.  
  609.       case INSN:
  610.     body = PATTERN (insn);
  611.     if (GET_CODE (body) == USE || GET_CODE (body) == CLOBBER)
  612.       return 0;
  613.  
  614.     else if (GET_CODE (body) == ASM_INPUT || asm_noperands (body) >= 0)
  615.       length = asm_insn_count (body) * insn_default_length (insn);
  616.     else if (GET_CODE (body) == SEQUENCE)
  617.       for (i = 0; i < XVECLEN (body, 0); i++)
  618.         length += get_attr_length (XVECEXP (body, 0, i));
  619.     else
  620.       length = insn_default_length (insn);
  621.       }
  622.  
  623. #ifdef ADJUST_INSN_LENGTH
  624.   ADJUST_INSN_LENGTH (insn, length);
  625. #endif
  626.   return length;
  627. #else /* not HAVE_ATTR_length */
  628.   return 0;
  629. #endif /* not HAVE_ATTR_length */
  630. }
  631.  
  632. /* Make a pass over all insns and compute their actual lengths by shortening
  633.    any branches of variable length if possible.  */
  634.  
  635. /* Give a default value for the lowest address in a function.  */
  636.  
  637. #ifndef FIRST_INSN_ADDRESS
  638. #define FIRST_INSN_ADDRESS 0
  639. #endif
  640.  
  641. void
  642. shorten_branches (first)
  643.      rtx first;
  644. {
  645. #ifdef HAVE_ATTR_length
  646.   rtx insn;
  647.   int something_changed = 1;
  648.   int max_uid = 0;
  649.   char *varying_length;
  650.   rtx body;
  651.   int uid;
  652.  
  653.   /* Compute maximum UID and allocate arrays.  */
  654.   for (insn = first; insn; insn = NEXT_INSN (insn))
  655.     if (INSN_UID (insn) > max_uid)
  656.       max_uid = INSN_UID (insn);
  657.  
  658.   max_uid++;
  659.   insn_lengths = (short *) oballoc (max_uid * sizeof (short));
  660.   insn_addresses = (int *) oballoc (max_uid * sizeof (int));
  661.   varying_length = (char *) oballoc (max_uid * sizeof (char));
  662.  
  663.   /* Compute initial lengths, addresses, and varying flags for each insn.  */
  664.   for (insn_current_address = FIRST_INSN_ADDRESS, insn = first;
  665.        insn != 0;
  666.        insn_current_address += insn_lengths[uid], insn = NEXT_INSN (insn))
  667.     {
  668.       uid = INSN_UID (insn);
  669.       insn_addresses[uid] = insn_current_address;
  670.       insn_lengths[uid] = 0;
  671.       varying_length[uid] = 0;
  672.       
  673.       if (GET_CODE (insn) == NOTE || GET_CODE (insn) == BARRIER
  674.       || GET_CODE (insn) == CODE_LABEL)
  675.     continue;
  676.  
  677.       body = PATTERN (insn);
  678.       if (GET_CODE (body) == ADDR_VEC || GET_CODE (body) == ADDR_DIFF_VEC)
  679.     {
  680.       /* This only takes room if read-only data goes into the text
  681.          section.  */
  682. #if !defined(READONLY_DATA_SECTION) || defined(JUMP_TABLES_IN_TEXT_SECTION)
  683.       int unitsize = GET_MODE_SIZE (GET_MODE (body));
  684.  
  685.       insn_lengths[uid] = (XVECLEN (body, GET_CODE (body) == ADDR_DIFF_VEC)
  686.                    * GET_MODE_SIZE (GET_MODE (body)));
  687.  
  688.       /* Account for possible alignment.  */
  689.       insn_lengths[uid]
  690.         += unitsize - (insn_current_address & (unitsize - 1));
  691. #else
  692.       ;
  693. #endif
  694.     }
  695.       else if (asm_noperands (body) >= 0)
  696.     insn_lengths[uid] = asm_insn_count (body) * insn_default_length (insn);
  697.       else if (GET_CODE (body) == SEQUENCE)
  698.     {
  699.       int i;
  700.       int const_delay_slots;
  701. #ifdef DELAY_SLOTS
  702.       const_delay_slots = const_num_delay_slots (XVECEXP (body, 0, 0));
  703. #else
  704.       const_delay_slots = 0;
  705. #endif
  706.       /* Inside a delay slot sequence, we do not do any branch shortening
  707.          if the shortening could change the number of delay slots
  708.          of the branch. */
  709.       for (i = 0; i < XVECLEN (body, 0); i++)
  710.         {
  711.           rtx inner_insn = XVECEXP (body, 0, i);
  712.           int inner_uid = INSN_UID (inner_insn);
  713.           int inner_length;
  714.  
  715.           if (asm_noperands (PATTERN (XVECEXP (body, 0, i))) >= 0)
  716.         inner_length = (asm_insn_count (PATTERN (inner_insn))
  717.                 * insn_default_length (inner_insn));
  718.           else
  719.         inner_length = insn_default_length (inner_insn);
  720.           
  721.           insn_lengths[inner_uid] = inner_length;
  722.           if (const_delay_slots)
  723.         {
  724.           if ((varying_length[inner_uid]
  725.                = insn_variable_length_p (inner_insn)) != 0)
  726.             varying_length[uid] = 1;
  727.           insn_addresses[inner_uid] = (insn_current_address +
  728.                            insn_lengths[uid]);
  729.         }
  730.           else
  731.         varying_length[inner_uid] = 0;
  732.           insn_lengths[uid] += inner_length;
  733.         }
  734.     }
  735.       else if (GET_CODE (body) != USE && GET_CODE (body) != CLOBBER)
  736.     {
  737.       insn_lengths[uid] = insn_default_length (insn);
  738.       varying_length[uid] = insn_variable_length_p (insn);
  739.     }
  740.  
  741.       /* If needed, do any adjustment.  */
  742. #ifdef ADJUST_INSN_LENGTH
  743.       ADJUST_INSN_LENGTH (insn, insn_lengths[uid]);
  744. #endif
  745.     }
  746.  
  747.   /* Now loop over all the insns finding varying length insns.  For each,
  748.      get the current insn length.  If it has changed, reflect the change.
  749.      When nothing changes for a full pass, we are done.  */
  750.  
  751.   while (something_changed)
  752.     {
  753.       something_changed = 0;
  754.       for (insn_current_address = FIRST_INSN_ADDRESS, insn = first;
  755.        insn != 0;
  756.        insn = NEXT_INSN (insn))
  757.     {
  758.       int new_length;
  759.       int tmp_length;
  760.  
  761.       uid = INSN_UID (insn);
  762.       insn_addresses[uid] = insn_current_address;
  763.       if (! varying_length[uid])
  764.         {
  765.           insn_current_address += insn_lengths[uid];
  766.           continue;
  767.         }
  768.       if (GET_CODE (insn) == INSN && GET_CODE (PATTERN (insn)) == SEQUENCE)
  769.         {
  770.           int i;
  771.           
  772.           body = PATTERN (insn);
  773.           new_length = 0;
  774.           for (i = 0; i < XVECLEN (body, 0); i++)
  775.         {
  776.           rtx inner_insn = XVECEXP (body, 0, i);
  777.           int inner_uid = INSN_UID (inner_insn);
  778.           int inner_length;
  779.  
  780.           insn_addresses[inner_uid] = insn_current_address;
  781.  
  782.           /* insn_current_length returns 0 for insns with a
  783.              non-varying length.  */
  784.           if (! varying_length[inner_uid])
  785.             inner_length = insn_lengths[inner_uid];
  786.           else
  787.             inner_length = insn_current_length (inner_insn);
  788.  
  789.           if (inner_length != insn_lengths[inner_uid])
  790.             {
  791.               insn_lengths[inner_uid] = inner_length;
  792.               something_changed = 1;
  793.             }
  794.           insn_current_address += insn_lengths[inner_uid];
  795.           new_length += inner_length;
  796.         }
  797.         }
  798.       else
  799.         {
  800.           new_length = insn_current_length (insn);
  801.           insn_current_address += new_length;
  802.         }
  803.  
  804. #ifdef SHORTEN_WITH_ADJUST_INSN_LENGTH
  805. #ifdef ADJUST_INSN_LENGTH
  806.       /* If needed, do any adjustment.  */
  807.       tmp_length = new_length;
  808.       ADJUST_INSN_LENGTH (insn, new_length);
  809.       insn_current_address += (new_length - tmp_length);
  810. #endif
  811. #endif
  812.  
  813.       if (new_length != insn_lengths[uid])
  814.         {
  815.           insn_lengths[uid] = new_length;
  816.           something_changed = 1;
  817.         }
  818.     }
  819.       /* For a non-optimizing compile, do only a single pass.  */
  820.       if (!optimize)
  821.     break;
  822.     }
  823. #endif /* HAVE_ATTR_length */
  824. }
  825.  
  826. #ifdef HAVE_ATTR_length
  827. /* Given the body of an INSN known to be generated by an ASM statement, return
  828.    the number of machine instructions likely to be generated for this insn.
  829.    This is used to compute its length.  */
  830.  
  831. static int
  832. asm_insn_count (body)
  833.      rtx body;
  834. {
  835.   char *template;
  836.   int count = 1;
  837.  
  838.   if (GET_CODE (body) == ASM_INPUT)
  839.     template = XSTR (body, 0);
  840.   else
  841.     template = decode_asm_operands (body, NULL_PTR, NULL_PTR,
  842.                     NULL_PTR, NULL_PTR);
  843.  
  844.   for ( ; *template; template++)
  845.     if (IS_ASM_LOGICAL_LINE_SEPARATOR(*template) || *template == '\n')
  846.       count++;
  847.  
  848.   return count;
  849. }
  850. #endif
  851.  
  852. /* Output assembler code for the start of a function,
  853.    and initialize some of the variables in this file
  854.    for the new function.  The label for the function and associated
  855.    assembler pseudo-ops have already been output in `assemble_start_function'.
  856.  
  857.    FIRST is the first insn of the rtl for the function being compiled.
  858.    FILE is the file to write assembler code to.
  859.    OPTIMIZE is nonzero if we should eliminate redundant
  860.      test and compare insns.  */
  861.  
  862. void
  863. final_start_function (first, file, optimize)
  864.      rtx first;
  865.      FILE *file;
  866.      int optimize;
  867. {
  868.   block_depth = 0;
  869.  
  870.   this_is_asm_operands = 0;
  871.  
  872. #ifdef NON_SAVING_SETJMP
  873.   /* A function that calls setjmp should save and restore all the
  874.      call-saved registers on a system where longjmp clobbers them.  */
  875.   if (NON_SAVING_SETJMP && current_function_calls_setjmp)
  876.     {
  877.       int i;
  878.  
  879.       for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
  880.     if (!call_used_regs[i] && !call_fixed_regs[i])
  881.       regs_ever_live[i] = 1;
  882.     }
  883. #endif
  884.   
  885.   /* Initial line number is supposed to be output
  886.      before the function's prologue and label
  887.      so that the function's address will not appear to be
  888.      in the last statement of the preceding function.  */
  889.   if (NOTE_LINE_NUMBER (first) != NOTE_INSN_DELETED)
  890.     {
  891.       last_linenum = high_block_linenum = high_function_linenum
  892.     = NOTE_LINE_NUMBER (first);
  893.  
  894.       if (write_symbols == SDB_DEBUG)
  895.     /* For sdb, let's not, but say we did.
  896.        We need to set last_linenum for sdbout_function_begin,
  897.        but we can't have an actual line number before the .bf symbol.
  898.        (sdb_begin_function_line is not set,
  899.        and other compilers don't do it.)  */
  900.     ;
  901. #ifdef XCOFF_DEBUGGING_INFO
  902.       else if (write_symbols == XCOFF_DEBUG)
  903.     xcoffout_output_first_source_line (file, last_linenum);
  904. #endif      
  905.       else
  906.     output_source_line (file, first);
  907.     }
  908.  
  909. #ifdef LEAF_REG_REMAP
  910.   if (leaf_function)
  911.     leaf_renumber_regs (first);
  912. #endif
  913.  
  914.   /* The Sun386i and perhaps other machines don't work right
  915.      if the profiling code comes after the prologue.  */
  916. #ifdef PROFILE_BEFORE_PROLOGUE
  917.   if (profile_flag)
  918.     profile_function (file);
  919. #endif /* PROFILE_BEFORE_PROLOGUE */
  920.  
  921. #ifdef FUNCTION_PROLOGUE
  922.   /* First output the function prologue: code to set up the stack frame.  */
  923.   FUNCTION_PROLOGUE (file, get_frame_size ());
  924. #endif
  925.  
  926. #if defined (SDB_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
  927.   if (write_symbols == SDB_DEBUG || write_symbols == XCOFF_DEBUG)
  928.     next_block_index = 1;
  929. #endif
  930.  
  931.   /* If the machine represents the prologue as RTL, the profiling code must
  932.      be emitted when NOTE_INSN_PROLOGUE_END is scanned.  */
  933. #ifdef HAVE_prologue
  934.   if (! HAVE_prologue)
  935. #endif
  936.     profile_after_prologue (file);
  937.  
  938.   profile_label_no++;
  939.  
  940.   /* If we are doing basic block profiling, remember a printable version
  941.      of the function name.  */
  942.   if (profile_block_flag)
  943.     {
  944.       char *junk = "function";
  945.       bb_func_label_num =
  946.     add_bb_string ((*decl_printable_name) (current_function_decl, &junk), FALSE);
  947.     }
  948. }
  949.  
  950. static void
  951. profile_after_prologue (file)
  952.      FILE *file;
  953. {
  954. #ifdef FUNCTION_BLOCK_PROFILER
  955.   if (profile_block_flag)
  956.     {
  957.       FUNCTION_BLOCK_PROFILER (file, profile_label_no);
  958.     }
  959. #endif /* FUNCTION_BLOCK_PROFILER */
  960.  
  961. #ifndef PROFILE_BEFORE_PROLOGUE
  962.   if (profile_flag)
  963.     profile_function (file);
  964. #endif /* not PROFILE_BEFORE_PROLOGUE */
  965. }
  966.  
  967. static void
  968. profile_function (file)
  969.      FILE *file;
  970. {
  971.   int align = MIN (BIGGEST_ALIGNMENT, POINTER_SIZE);
  972.   int sval = current_function_returns_struct;
  973.   int cxt = current_function_needs_context;
  974.  
  975.   data_section ();
  976.   ASM_OUTPUT_ALIGN (file, floor_log2 (align / BITS_PER_UNIT));
  977.   ASM_OUTPUT_INTERNAL_LABEL (file, "LP", profile_label_no);
  978.   assemble_integer (const0_rtx, POINTER_SIZE / BITS_PER_UNIT, 1);
  979.  
  980.   text_section ();
  981.  
  982. #ifdef STRUCT_VALUE_INCOMING_REGNUM
  983.   if (sval)
  984.     ASM_OUTPUT_REG_PUSH (file, STRUCT_VALUE_INCOMING_REGNUM);
  985. #else
  986. #ifdef STRUCT_VALUE_REGNUM
  987.   if (sval)
  988.     ASM_OUTPUT_REG_PUSH (file, STRUCT_VALUE_REGNUM);
  989. #endif
  990. #endif
  991.  
  992. #if 0
  993. #ifdef STATIC_CHAIN_INCOMING_REGNUM
  994.   if (cxt)
  995.     ASM_OUTPUT_REG_PUSH (file, STATIC_CHAIN_INCOMING_REGNUM);
  996. #else
  997. #ifdef STATIC_CHAIN_REGNUM
  998.   if (cxt)
  999.     ASM_OUTPUT_REG_PUSH (file, STATIC_CHAIN_REGNUM);
  1000. #endif
  1001. #endif
  1002. #endif                /* 0 */
  1003.  
  1004.   FUNCTION_PROFILER (file, profile_label_no);
  1005.  
  1006. #if 0
  1007. #ifdef STATIC_CHAIN_INCOMING_REGNUM
  1008.   if (cxt)
  1009.     ASM_OUTPUT_REG_POP (file, STATIC_CHAIN_INCOMING_REGNUM);
  1010. #else
  1011. #ifdef STATIC_CHAIN_REGNUM
  1012.   if (cxt)
  1013.     ASM_OUTPUT_REG_POP (file, STATIC_CHAIN_REGNUM);
  1014. #endif
  1015. #endif
  1016. #endif                /* 0 */
  1017.  
  1018. #ifdef STRUCT_VALUE_INCOMING_REGNUM
  1019.   if (sval)
  1020.     ASM_OUTPUT_REG_POP (file, STRUCT_VALUE_INCOMING_REGNUM);
  1021. #else
  1022. #ifdef STRUCT_VALUE_REGNUM
  1023.   if (sval)
  1024.     ASM_OUTPUT_REG_POP (file, STRUCT_VALUE_REGNUM);
  1025. #endif
  1026. #endif
  1027. }
  1028.  
  1029. /* Output assembler code for the end of a function.
  1030.    For clarity, args are same as those of `final_start_function'
  1031.    even though not all of them are needed.  */
  1032.  
  1033. void
  1034. final_end_function (first, file, optimize)
  1035.      rtx first;
  1036.      FILE *file;
  1037.      int optimize;
  1038. {
  1039.   if (app_on)
  1040.     {
  1041.       fprintf (file, ASM_APP_OFF);
  1042.       app_on = 0;
  1043.     }
  1044.  
  1045. #ifdef SDB_DEBUGGING_INFO
  1046.   if (write_symbols == SDB_DEBUG)
  1047.     sdbout_end_function (high_function_linenum);
  1048. #endif
  1049.  
  1050. #ifdef DWARF_DEBUGGING_INFO
  1051.   if (write_symbols == DWARF_DEBUG)
  1052.     dwarfout_end_function ();
  1053. #endif
  1054.  
  1055. #ifdef XCOFF_DEBUGGING_INFO
  1056.   if (write_symbols == XCOFF_DEBUG)
  1057.     xcoffout_end_function (file, high_function_linenum);
  1058. #endif
  1059.  
  1060. #ifdef FUNCTION_EPILOGUE
  1061.   /* Finally, output the function epilogue:
  1062.      code to restore the stack frame and return to the caller.  */
  1063.   FUNCTION_EPILOGUE (file, get_frame_size ());
  1064. #endif
  1065.  
  1066. #ifdef SDB_DEBUGGING_INFO
  1067.   if (write_symbols == SDB_DEBUG)
  1068.     sdbout_end_epilogue ();
  1069. #endif
  1070.  
  1071. #ifdef DWARF_DEBUGGING_INFO
  1072.   if (write_symbols == DWARF_DEBUG)
  1073.     dwarfout_end_epilogue ();
  1074. #endif
  1075.  
  1076. #ifdef XCOFF_DEBUGGING_INFO
  1077.   if (write_symbols == XCOFF_DEBUG)
  1078.     xcoffout_end_epilogue (file);
  1079. #endif
  1080.  
  1081.   bb_func_label_num = -1;    /* not in function, nuke label # */
  1082.  
  1083.   /* If FUNCTION_EPILOGUE is not defined, then the function body
  1084.      itself contains return instructions wherever needed.  */
  1085. }
  1086.  
  1087. /* Add a block to the linked list that remembers the current line/file/function
  1088.    for basic block profiling.  Emit the label in front of the basic block and
  1089.    the instructions that increment the count field.  */
  1090.  
  1091. static void
  1092. add_bb (file)
  1093.      FILE *file;
  1094. {
  1095.   struct bb_list *ptr = (struct bb_list *) permalloc (sizeof (struct bb_list));
  1096.  
  1097.   /* Add basic block to linked list.  */
  1098.   ptr->next = 0;
  1099.   ptr->line_num = last_linenum;
  1100.   ptr->file_label_num = bb_file_label_num;
  1101.   ptr->func_label_num = bb_func_label_num;
  1102.   *bb_tail = ptr;
  1103.   bb_tail = &ptr->next;
  1104.  
  1105.   /* Enable the table of basic-block use counts
  1106.      to point at the code it applies to.  */
  1107.   ASM_OUTPUT_INTERNAL_LABEL (file, "LPB", count_basic_blocks);
  1108.  
  1109.   /* Before first insn of this basic block, increment the
  1110.      count of times it was entered.  */
  1111. #ifdef BLOCK_PROFILER
  1112.   BLOCK_PROFILER (file, count_basic_blocks);
  1113.   CC_STATUS_INIT;
  1114. #endif
  1115.  
  1116.   new_block = 0;
  1117.   count_basic_blocks++;
  1118. }
  1119.  
  1120. /* Add a string to be used for basic block profiling.  */
  1121.  
  1122. static int
  1123. add_bb_string (string, perm_p)
  1124.      char *string;
  1125.      int perm_p;
  1126. {
  1127.   int len;
  1128.   struct bb_str *ptr = 0;
  1129.  
  1130.   if (!string)
  1131.     {
  1132.       string = "<unknown>";
  1133.       perm_p = TRUE;
  1134.     }
  1135.  
  1136.   /* Allocate a new string if the current string isn't permanent.  If
  1137.      the string is permanent search for the same string in other
  1138.      allocations.  */
  1139.  
  1140.   len = strlen (string) + 1;
  1141.   if (!perm_p)
  1142.     {
  1143.       char *p = (char *) permalloc (len);
  1144.       bcopy (string, p, len);
  1145.       string = p;
  1146.     }
  1147.   else
  1148.     for (ptr = sbb_head; ptr != (struct bb_str *)0; ptr = ptr->next)
  1149.       if (ptr->string == string)
  1150.     break;
  1151.  
  1152.   /* Allocate a new string block if we need to.  */
  1153.   if (!ptr)
  1154.     {
  1155.       ptr = (struct bb_str *) permalloc (sizeof (*ptr));
  1156.       ptr->next = 0;
  1157.       ptr->length = len;
  1158.       ptr->label_num = sbb_label_num++;
  1159.       ptr->string = string;
  1160.       *sbb_tail = ptr;
  1161.       sbb_tail = &ptr->next;
  1162.     }
  1163.  
  1164.   return ptr->label_num;
  1165. }
  1166.  
  1167.  
  1168. /* Output assembler code for some insns: all or part of a function.
  1169.    For description of args, see `final_start_function', above.
  1170.  
  1171.    PRESCAN is 1 if we are not really outputting,
  1172.      just scanning as if we were outputting.
  1173.    Prescanning deletes and rearranges insns just like ordinary output.
  1174.    PRESCAN is -2 if we are outputting after having prescanned.
  1175.    In this case, don't try to delete or rearrange insns
  1176.    because that has already been done.
  1177.    Prescanning is done only on certain machines.  */
  1178.  
  1179. void
  1180. final (first, file, optimize, prescan)
  1181.      rtx first;
  1182.      FILE *file;
  1183.      int optimize;
  1184.      int prescan;
  1185. {
  1186.   register rtx insn;
  1187.   int max_line = 0;
  1188.  
  1189.   last_ignored_compare = 0;
  1190.   new_block = 1;
  1191.  
  1192.   /* Make a map indicating which line numbers appear in this function.
  1193.      When producing SDB debugging info, delete troublesome line number
  1194.      notes from inlined functions in other files as well as duplicate
  1195.      line number notes.  */
  1196. #ifdef SDB_DEBUGGING_INFO
  1197.   if (write_symbols == SDB_DEBUG)
  1198.     {
  1199.       rtx last = 0;
  1200.       for (insn = first; insn; insn = NEXT_INSN (insn))
  1201.     if (GET_CODE (insn) == NOTE && NOTE_LINE_NUMBER (insn) > 0)
  1202.       {
  1203.         if ((RTX_INTEGRATED_P (insn)
  1204.          && strcmp (NOTE_SOURCE_FILE (insn), main_input_filename) != 0)
  1205.          || (last != 0
  1206.              && NOTE_LINE_NUMBER (insn) == NOTE_LINE_NUMBER (last)
  1207.              && NOTE_SOURCE_FILE (insn) == NOTE_SOURCE_FILE (last)))
  1208.           {
  1209.         NOTE_LINE_NUMBER (insn) = NOTE_INSN_DELETED;
  1210.         NOTE_SOURCE_FILE (insn) = 0;
  1211.         continue;
  1212.           }
  1213.         last = insn;
  1214.         if (NOTE_LINE_NUMBER (insn) > max_line)
  1215.           max_line = NOTE_LINE_NUMBER (insn);
  1216.       }
  1217.     }
  1218.   else
  1219. #endif
  1220.     {
  1221.       for (insn = first; insn; insn = NEXT_INSN (insn))
  1222.     if (GET_CODE (insn) == NOTE && NOTE_LINE_NUMBER (insn) > max_line)
  1223.       max_line = NOTE_LINE_NUMBER (insn);
  1224.     }
  1225.  
  1226.   line_note_exists = (char *) oballoc (max_line + 1);
  1227.   bzero (line_note_exists, max_line + 1);
  1228.  
  1229.   for (insn = first; insn; insn = NEXT_INSN (insn))
  1230.     if (GET_CODE (insn) == NOTE && NOTE_LINE_NUMBER (insn) > 0)
  1231.       line_note_exists[NOTE_LINE_NUMBER (insn)] = 1;
  1232.  
  1233.   init_recog ();
  1234.  
  1235.   CC_STATUS_INIT;
  1236.  
  1237.   /* Output the insns.  */
  1238.   for (insn = NEXT_INSN (first); insn;)
  1239.     insn = final_scan_insn (insn, file, optimize, prescan, 0);
  1240.  
  1241.   /* Do basic-block profiling here
  1242.      if the last insn was a conditional branch.  */
  1243.   if (profile_block_flag && new_block)
  1244.     add_bb (file);
  1245. }
  1246.  
  1247. /* The final scan for one insn, INSN.
  1248.    Args are same as in `final', except that INSN
  1249.    is the insn being scanned.
  1250.    Value returned is the next insn to be scanned.
  1251.  
  1252.    NOPEEPHOLES is the flag to disallow peephole processing (currently
  1253.    used for within delayed branch sequence output).  */
  1254.  
  1255. rtx
  1256. final_scan_insn (insn, file, optimize, prescan, nopeepholes)
  1257.      rtx insn;
  1258.      FILE *file;
  1259.      int optimize;
  1260.      int prescan;
  1261.      int nopeepholes;
  1262. {
  1263.   register int i;
  1264.   insn_counter++;
  1265.  
  1266.   /* Ignore deleted insns.  These can occur when we split insns (due to a
  1267.      template of "#") while not optimizing.  */
  1268.   if (INSN_DELETED_P (insn))
  1269.     return NEXT_INSN (insn);
  1270.  
  1271.   switch (GET_CODE (insn))
  1272.     {
  1273.     case NOTE:
  1274.       if (prescan > 0)
  1275.     break;
  1276.  
  1277.       /* Align the beginning of a loop, for higher speed
  1278.      on certain machines.  */
  1279.  
  1280.       if (NOTE_LINE_NUMBER (insn) == NOTE_INSN_LOOP_BEG && optimize > 0)
  1281.     {
  1282. #ifdef ASM_OUTPUT_LOOP_ALIGN
  1283.       rtx next = next_nonnote_insn (insn);
  1284.       if (next && GET_CODE (next) == CODE_LABEL)
  1285.         {
  1286.           ASM_OUTPUT_LOOP_ALIGN (asm_out_file);
  1287.         }
  1288. #endif
  1289.       break;
  1290.     }
  1291.       if (NOTE_LINE_NUMBER (insn) == NOTE_INSN_LOOP_END)
  1292.     break;
  1293.  
  1294.       if (NOTE_LINE_NUMBER (insn) == NOTE_INSN_PROLOGUE_END)
  1295.     {
  1296. #ifdef FUNCTION_END_PROLOGUE
  1297.       FUNCTION_END_PROLOGUE (file);
  1298. #endif
  1299.       profile_after_prologue (file);
  1300.       break;
  1301.     }
  1302.  
  1303. #ifdef FUNCTION_BEGIN_EPILOGUE
  1304.       if (NOTE_LINE_NUMBER (insn) == NOTE_INSN_EPILOGUE_BEG)
  1305.     {
  1306.       FUNCTION_BEGIN_EPILOGUE (file);
  1307.       break;
  1308.     }
  1309. #endif
  1310.  
  1311.       if (write_symbols == NO_DEBUG)
  1312.     break;
  1313.       if (NOTE_LINE_NUMBER (insn) == NOTE_INSN_FUNCTION_BEG)
  1314.     {
  1315. #ifdef SDB_DEBUGGING_INFO
  1316.       if (write_symbols == SDB_DEBUG)
  1317.         sdbout_begin_function (last_linenum);
  1318. #endif
  1319. #ifdef XCOFF_DEBUGGING_INFO
  1320.       if (write_symbols == XCOFF_DEBUG)
  1321.         xcoffout_begin_function (file, last_linenum);
  1322. #endif
  1323. #ifdef DWARF_DEBUGGING_INFO
  1324.       if (write_symbols == DWARF_DEBUG)
  1325.         dwarfout_begin_function ();
  1326. #endif
  1327.       break;
  1328.     }
  1329.       if (NOTE_LINE_NUMBER (insn) == NOTE_INSN_DELETED)
  1330.     break;            /* An insn that was "deleted" */
  1331.       if (app_on)
  1332.     {
  1333.       fprintf (file, ASM_APP_OFF);
  1334.       app_on = 0;
  1335.     }
  1336.       if (NOTE_LINE_NUMBER (insn) == NOTE_INSN_BLOCK_BEG
  1337.       && (debug_info_level == DINFO_LEVEL_NORMAL
  1338.           || debug_info_level == DINFO_LEVEL_VERBOSE
  1339. #ifdef DWARF_DEBUGGING_INFO
  1340.           || write_symbols == DWARF_DEBUG
  1341. #endif
  1342.          )
  1343.      )
  1344.     {
  1345.       /* Beginning of a symbol-block.  Assign it a sequence number
  1346.          and push the number onto the stack PENDING_BLOCKS.  */
  1347.  
  1348.       if (block_depth == max_block_depth)
  1349.         {
  1350.           /* PENDING_BLOCKS is full; make it longer.  */
  1351.           max_block_depth *= 2;
  1352.           pending_blocks
  1353.         = (int *) xrealloc (pending_blocks,
  1354.                     max_block_depth * sizeof (int));
  1355.         }
  1356.       pending_blocks[block_depth++] = next_block_index;
  1357.  
  1358.       high_block_linenum = last_linenum;
  1359.  
  1360.       /* Output debugging info about the symbol-block beginning.  */
  1361.  
  1362. #ifdef SDB_DEBUGGING_INFO
  1363.       if (write_symbols == SDB_DEBUG)
  1364.         sdbout_begin_block (file, last_linenum, next_block_index);
  1365. #endif
  1366. #ifdef XCOFF_DEBUGGING_INFO
  1367.       if (write_symbols == XCOFF_DEBUG)
  1368.         xcoffout_begin_block (file, last_linenum, next_block_index);
  1369. #endif
  1370. #ifdef DBX_DEBUGGING_INFO
  1371.       if (write_symbols == DBX_DEBUG)
  1372.         ASM_OUTPUT_INTERNAL_LABEL (file, "LBB", next_block_index);
  1373. #endif
  1374. #ifdef DWARF_DEBUGGING_INFO
  1375.       if (write_symbols == DWARF_DEBUG && block_depth > 1)
  1376.         dwarfout_begin_block (next_block_index);
  1377. #endif
  1378.  
  1379.       next_block_index++;
  1380.     }
  1381.       else if (NOTE_LINE_NUMBER (insn) == NOTE_INSN_BLOCK_END
  1382.            && (debug_info_level == DINFO_LEVEL_NORMAL
  1383.            || debug_info_level == DINFO_LEVEL_VERBOSE
  1384. #ifdef DWARF_DEBUGGING_INFO
  1385.                || write_symbols == DWARF_DEBUG
  1386. #endif
  1387.               )
  1388.           )
  1389.     {
  1390.       /* End of a symbol-block.  Pop its sequence number off
  1391.          PENDING_BLOCKS and output debugging info based on that.  */
  1392.  
  1393.       --block_depth;
  1394.  
  1395. #ifdef XCOFF_DEBUGGING_INFO
  1396.       if (write_symbols == XCOFF_DEBUG && block_depth >= 0)
  1397.         xcoffout_end_block (file, high_block_linenum,
  1398.                 pending_blocks[block_depth]);
  1399. #endif
  1400. #ifdef DBX_DEBUGGING_INFO
  1401.       if (write_symbols == DBX_DEBUG && block_depth >= 0)
  1402.         ASM_OUTPUT_INTERNAL_LABEL (file, "LBE",
  1403.                        pending_blocks[block_depth]);
  1404. #endif
  1405. #ifdef SDB_DEBUGGING_INFO
  1406.       if (write_symbols == SDB_DEBUG && block_depth >= 0)
  1407.         sdbout_end_block (file, high_block_linenum,
  1408.                   pending_blocks[block_depth]);
  1409. #endif
  1410. #ifdef DWARF_DEBUGGING_INFO
  1411.       if (write_symbols == DWARF_DEBUG && block_depth >= 1)
  1412.         dwarfout_end_block (pending_blocks[block_depth]);
  1413. #endif
  1414.     }
  1415.       else if (NOTE_LINE_NUMBER (insn) == NOTE_INSN_DELETED_LABEL
  1416.            && (debug_info_level == DINFO_LEVEL_NORMAL
  1417.            || debug_info_level == DINFO_LEVEL_VERBOSE))
  1418.     {
  1419. #ifdef DWARF_DEBUGGING_INFO
  1420.           if (write_symbols == DWARF_DEBUG)
  1421.             dwarfout_label (insn);
  1422. #endif
  1423.     }
  1424.       else if (NOTE_LINE_NUMBER (insn) > 0)
  1425.     /* This note is a line-number.  */
  1426.     {
  1427.       register rtx note;
  1428.  
  1429. #if 0 /* This is what we used to do.  */
  1430.       output_source_line (file, insn);
  1431. #endif
  1432.       int note_after = 0;
  1433.  
  1434.       /* If there is anything real after this note,
  1435.          output it.  If another line note follows, omit this one.  */
  1436.       for (note = NEXT_INSN (insn); note; note = NEXT_INSN (note))
  1437.         {
  1438.           if (GET_CODE (note) != NOTE && GET_CODE (note) != CODE_LABEL)
  1439.         break;
  1440.           /* These types of notes can be significant
  1441.          so make sure the preceding line number stays.  */
  1442.           else if (GET_CODE (note) == NOTE
  1443.                && (NOTE_LINE_NUMBER (note) == NOTE_INSN_BLOCK_BEG
  1444.                || NOTE_LINE_NUMBER (note) == NOTE_INSN_BLOCK_END
  1445.                || NOTE_LINE_NUMBER (note) == NOTE_INSN_FUNCTION_BEG))
  1446.           break;
  1447.           else if (GET_CODE (note) == NOTE && NOTE_LINE_NUMBER (note) > 0)
  1448.         {
  1449.           /* Another line note follows; we can delete this note
  1450.              if no intervening line numbers have notes elsewhere.  */
  1451.           int num;
  1452.           for (num = NOTE_LINE_NUMBER (insn) + 1;
  1453.                num < NOTE_LINE_NUMBER (note);
  1454.                num++)
  1455.             if (line_note_exists[num])
  1456.               break;
  1457.  
  1458.           if (num >= NOTE_LINE_NUMBER (note))
  1459.             note_after = 1;
  1460.           break;
  1461.         }
  1462.         }
  1463.  
  1464.       /* Output this line note
  1465.          if it is the first or the last line note in a row.  */
  1466.       if (!note_after)
  1467.         output_source_line (file, insn);
  1468.     }
  1469.       break;
  1470.  
  1471.     case BARRIER:
  1472. #ifdef ASM_OUTPUT_ALIGN_CODE
  1473.       /* Don't litter the assembler output with needless alignments.  A
  1474.      BARRIER will be placed at the end of every function if HAVE_epilogue
  1475.      is true.  */     
  1476.       if (NEXT_INSN (insn))
  1477.     ASM_OUTPUT_ALIGN_CODE (file);
  1478. #endif
  1479.       break;
  1480.  
  1481.     case CODE_LABEL:
  1482.       CC_STATUS_INIT;
  1483.       if (prescan > 0)
  1484.     break;
  1485.       new_block = 1;
  1486. #ifdef SDB_DEBUGGING_INFO
  1487.       if (write_symbols == SDB_DEBUG && LABEL_NAME (insn))
  1488.     sdbout_label (insn);
  1489. #endif
  1490. #ifdef DWARF_DEBUGGING_INFO
  1491.       if (write_symbols == DWARF_DEBUG && LABEL_NAME (insn))
  1492.     dwarfout_label (insn);
  1493. #endif
  1494.       if (app_on)
  1495.     {
  1496.       fprintf (file, ASM_APP_OFF);
  1497.       app_on = 0;
  1498.     }
  1499.       if (NEXT_INSN (insn) != 0
  1500.       && GET_CODE (NEXT_INSN (insn)) == JUMP_INSN)
  1501.     {
  1502.       rtx nextbody = PATTERN (NEXT_INSN (insn));
  1503.  
  1504.       /* If this label is followed by a jump-table,
  1505.          make sure we put the label in the read-only section.  Also
  1506.          possibly write the label and jump table together.  */
  1507.  
  1508.       if (GET_CODE (nextbody) == ADDR_VEC
  1509.           || GET_CODE (nextbody) == ADDR_DIFF_VEC)
  1510.         {
  1511. #ifndef JUMP_TABLES_IN_TEXT_SECTION
  1512.           readonly_data_section ();
  1513. #ifdef READONLY_DATA_SECTION
  1514.           ASM_OUTPUT_ALIGN (file,
  1515.                 exact_log2 (BIGGEST_ALIGNMENT
  1516.                         / BITS_PER_UNIT));
  1517. #endif /* READONLY_DATA_SECTION */
  1518. #else /* JUMP_TABLES_IN_TEXT_SECTION */
  1519.           function_section (current_function_decl);
  1520. #endif /* JUMP_TABLES_IN_TEXT_SECTION */
  1521. #ifdef ASM_OUTPUT_CASE_LABEL
  1522.           ASM_OUTPUT_CASE_LABEL (file, "L", CODE_LABEL_NUMBER (insn),
  1523.                      NEXT_INSN (insn));
  1524. #else
  1525.           ASM_OUTPUT_INTERNAL_LABEL (file, "L", CODE_LABEL_NUMBER (insn));
  1526. #endif
  1527.           break;
  1528.         }
  1529.     }
  1530.  
  1531.       ASM_OUTPUT_INTERNAL_LABEL (file, "L", CODE_LABEL_NUMBER (insn));
  1532.       break;
  1533.  
  1534.     default:
  1535.       {
  1536.     register rtx body = PATTERN (insn);
  1537.     int insn_code_number;
  1538.     char *template;
  1539.     rtx note;
  1540.  
  1541.     /* An INSN, JUMP_INSN or CALL_INSN.
  1542.        First check for special kinds that recog doesn't recognize.  */
  1543.  
  1544.     if (GET_CODE (body) == USE /* These are just declarations */
  1545.         || GET_CODE (body) == CLOBBER)
  1546.       break;
  1547.  
  1548. #ifdef HAVE_cc0
  1549.     /* If there is a REG_CC_SETTER note on this insn, it means that
  1550.        the setting of the condition code was done in the delay slot
  1551.        of the insn that branched here.  So recover the cc status
  1552.        from the insn that set it.  */
  1553.  
  1554.     note = find_reg_note (insn, REG_CC_SETTER, NULL_RTX);
  1555.     if (note)
  1556.       {
  1557.         NOTICE_UPDATE_CC (PATTERN (XEXP (note, 0)), XEXP (note, 0));
  1558.         cc_prev_status = cc_status;
  1559.       }
  1560. #endif
  1561.  
  1562.     /* Detect insns that are really jump-tables
  1563.        and output them as such.  */
  1564.  
  1565.     if (GET_CODE (body) == ADDR_VEC || GET_CODE (body) == ADDR_DIFF_VEC)
  1566.       {
  1567.         register int vlen, idx;
  1568.  
  1569.         if (prescan > 0)
  1570.           break;
  1571.  
  1572.         if (app_on)
  1573.           {
  1574.         fprintf (file, ASM_APP_OFF);
  1575.         app_on = 0;
  1576.           }
  1577.  
  1578.         vlen = XVECLEN (body, GET_CODE (body) == ADDR_DIFF_VEC);
  1579.         for (idx = 0; idx < vlen; idx++)
  1580.           {
  1581.         if (GET_CODE (body) == ADDR_VEC)
  1582.           {
  1583. #ifdef ASM_OUTPUT_ADDR_VEC_ELT
  1584.             ASM_OUTPUT_ADDR_VEC_ELT
  1585.               (file, CODE_LABEL_NUMBER (XEXP (XVECEXP (body, 0, idx), 0)));
  1586. #else
  1587.             abort ();
  1588. #endif
  1589.           }
  1590.         else
  1591.           {
  1592. #ifdef ASM_OUTPUT_ADDR_DIFF_ELT
  1593.             ASM_OUTPUT_ADDR_DIFF_ELT
  1594.               (file,
  1595.                CODE_LABEL_NUMBER (XEXP (XVECEXP (body, 1, idx), 0)),
  1596.                CODE_LABEL_NUMBER (XEXP (XEXP (body, 0), 0)));
  1597. #else
  1598.             abort ();
  1599. #endif
  1600.           }
  1601.           }
  1602. #ifdef ASM_OUTPUT_CASE_END
  1603.         ASM_OUTPUT_CASE_END (file,
  1604.                  CODE_LABEL_NUMBER (PREV_INSN (insn)),
  1605.                  insn);
  1606. #endif
  1607.  
  1608.         function_section (current_function_decl);
  1609.  
  1610.         break;
  1611.       }
  1612.  
  1613.     /* Do basic-block profiling when we reach a new block.
  1614.        Done here to avoid jump tables.  */
  1615.     if (profile_block_flag && new_block)
  1616.       add_bb (file);
  1617.  
  1618.     if (GET_CODE (body) == ASM_INPUT)
  1619.       {
  1620.         /* There's no telling what that did to the condition codes.  */
  1621.         CC_STATUS_INIT;
  1622.         if (prescan > 0)
  1623.           break;
  1624.         if (! app_on)
  1625.           {
  1626.         fprintf (file, ASM_APP_ON);
  1627.         app_on = 1;
  1628.           }
  1629.         fprintf (asm_out_file, "\t%s\n", XSTR (body, 0));
  1630.         break;
  1631.       }
  1632.  
  1633.     /* Detect `asm' construct with operands.  */
  1634.     if (asm_noperands (body) >= 0)
  1635.       {
  1636.         int noperands = asm_noperands (body);
  1637.         rtx *ops = (rtx *) alloca (noperands * sizeof (rtx));
  1638.         char *string;
  1639.  
  1640.         /* There's no telling what that did to the condition codes.  */
  1641.         CC_STATUS_INIT;
  1642.         if (prescan > 0)
  1643.           break;
  1644.  
  1645.         if (! app_on)
  1646.           {
  1647.         fprintf (file, ASM_APP_ON);
  1648.         app_on = 1;
  1649.           }
  1650.  
  1651.         /* Get out the operand values.  */
  1652.         string = decode_asm_operands (body, ops, NULL_PTR,
  1653.                       NULL_PTR, NULL_PTR);
  1654.         /* Inhibit aborts on what would otherwise be compiler bugs.  */
  1655.         insn_noperands = noperands;
  1656.         this_is_asm_operands = insn;
  1657.  
  1658.         /* Output the insn using them.  */
  1659.         output_asm_insn (string, ops);
  1660.         this_is_asm_operands = 0;
  1661.         break;
  1662.       }
  1663.  
  1664.     if (prescan <= 0 && app_on)
  1665.       {
  1666.         fprintf (file, ASM_APP_OFF);
  1667.         app_on = 0;
  1668.       }
  1669.  
  1670.     if (GET_CODE (body) == SEQUENCE)
  1671.       {
  1672.         /* A delayed-branch sequence */
  1673.         register int i;
  1674.         rtx next;
  1675.  
  1676.         if (prescan > 0)
  1677.           break;
  1678.         final_sequence = body;
  1679.  
  1680.         /* The first insn in this SEQUENCE might be a JUMP_INSN that will
  1681.            force the restoration of a comparison that was previously
  1682.            thought unnecessary.  If that happens, cancel this sequence
  1683.            and cause that insn to be restored.  */
  1684.  
  1685.         next = final_scan_insn (XVECEXP (body, 0, 0), file, 0, prescan, 1);
  1686.         if (next != XVECEXP (body, 0, 1))
  1687.           {
  1688.         final_sequence = 0;
  1689.         return next;
  1690.           }
  1691.  
  1692.         for (i = 1; i < XVECLEN (body, 0); i++)
  1693.           final_scan_insn (XVECEXP (body, 0, i), file, 0, prescan, 1);
  1694. #ifdef DBR_OUTPUT_SEQEND
  1695.         DBR_OUTPUT_SEQEND (file);
  1696. #endif
  1697.         final_sequence = 0;
  1698.  
  1699.         /* If the insn requiring the delay slot was a CALL_INSN, the
  1700.            insns in the delay slot are actually executed before the
  1701.            called function.  Hence we don't preserve any CC-setting
  1702.            actions in these insns and the CC must be marked as being
  1703.            clobbered by the function.  */
  1704.         if (GET_CODE (XVECEXP (body, 0, 0)) == CALL_INSN)
  1705.           CC_STATUS_INIT;
  1706.  
  1707.         /* Following a conditional branch sequence, we have a new basic
  1708.            block.  */
  1709.         if (profile_block_flag)
  1710.           {
  1711.         rtx insn = XVECEXP (body, 0, 0);
  1712.         rtx body = PATTERN (insn);
  1713.  
  1714.         if ((GET_CODE (insn) == JUMP_INSN && GET_CODE (body) == SET
  1715.              && GET_CODE (SET_SRC (body)) != LABEL_REF)
  1716.             || (GET_CODE (insn) == JUMP_INSN
  1717.             && GET_CODE (body) == PARALLEL
  1718.             && GET_CODE (XVECEXP (body, 0, 0)) == SET
  1719.             && GET_CODE (SET_SRC (XVECEXP (body, 0, 0))) != LABEL_REF))
  1720.           new_block = 1;
  1721.           }
  1722.         break;
  1723.       }
  1724.  
  1725.     /* We have a real machine instruction as rtl.  */
  1726.  
  1727.     body = PATTERN (insn);
  1728.  
  1729. #ifdef HAVE_cc0
  1730.     /* Check for redundant test and compare instructions
  1731.        (when the condition codes are already set up as desired).
  1732.        This is done only when optimizing; if not optimizing,
  1733.        it should be possible for the user to alter a variable
  1734.        with the debugger in between statements
  1735.        and the next statement should reexamine the variable
  1736.        to compute the condition codes.  */
  1737.  
  1738.     if (optimize
  1739.         && GET_CODE (body) == SET
  1740.         && GET_CODE (SET_DEST (body)) == CC0
  1741.         && insn != last_ignored_compare)
  1742.       {
  1743.         if (GET_CODE (SET_SRC (body)) == SUBREG)
  1744.           SET_SRC (body) = alter_subreg (SET_SRC (body));
  1745.         else if (GET_CODE (SET_SRC (body)) == COMPARE)
  1746.           {
  1747.         if (GET_CODE (XEXP (SET_SRC (body), 0)) == SUBREG)
  1748.           XEXP (SET_SRC (body), 0)
  1749.             = alter_subreg (XEXP (SET_SRC (body), 0));
  1750.         if (GET_CODE (XEXP (SET_SRC (body), 1)) == SUBREG)
  1751.           XEXP (SET_SRC (body), 1)
  1752.             = alter_subreg (XEXP (SET_SRC (body), 1));
  1753.           }
  1754.         if ((cc_status.value1 != 0
  1755.          && rtx_equal_p (SET_SRC (body), cc_status.value1))
  1756.         || (cc_status.value2 != 0
  1757.             && rtx_equal_p (SET_SRC (body), cc_status.value2)))
  1758.           {
  1759.         /* Don't delete insn if it has an addressing side-effect.  */
  1760.         if (! FIND_REG_INC_NOTE (insn, 0)
  1761.             /* or if anything in it is volatile.  */
  1762.             && ! volatile_refs_p (PATTERN (insn)))
  1763.           {
  1764.             /* We don't really delete the insn; just ignore it.  */
  1765.             last_ignored_compare = insn;
  1766.             break;
  1767.           }
  1768.           }
  1769.       }
  1770. #endif
  1771.  
  1772.     /* Following a conditional branch, we have a new basic block.
  1773.        But if we are inside a sequence, the new block starts after the
  1774.        last insn of the sequence.  */
  1775.     if (profile_block_flag && final_sequence == 0
  1776.         && ((GET_CODE (insn) == JUMP_INSN && GET_CODE (body) == SET
  1777.          && GET_CODE (SET_SRC (body)) != LABEL_REF)
  1778.         || (GET_CODE (insn) == JUMP_INSN && GET_CODE (body) == PARALLEL
  1779.             && GET_CODE (XVECEXP (body, 0, 0)) == SET
  1780.             && GET_CODE (SET_SRC (XVECEXP (body, 0, 0))) != LABEL_REF)))
  1781.       new_block = 1;
  1782.  
  1783. #ifndef STACK_REGS
  1784.     /* Don't bother outputting obvious no-ops, even without -O.
  1785.        This optimization is fast and doesn't interfere with debugging.
  1786.        Don't do this if the insn is in a delay slot, since this
  1787.        will cause an improper number of delay insns to be written.  */
  1788.     if (final_sequence == 0
  1789.         && prescan >= 0
  1790.         && GET_CODE (insn) == INSN && GET_CODE (body) == SET
  1791.         && GET_CODE (SET_SRC (body)) == REG
  1792.         && GET_CODE (SET_DEST (body)) == REG
  1793.         && REGNO (SET_SRC (body)) == REGNO (SET_DEST (body)))
  1794.       break;
  1795. #endif
  1796.  
  1797. #ifdef HAVE_cc0
  1798.     /* If this is a conditional branch, maybe modify it
  1799.        if the cc's are in a nonstandard state
  1800.        so that it accomplishes the same thing that it would
  1801.        do straightforwardly if the cc's were set up normally.  */
  1802.  
  1803.     if (cc_status.flags != 0
  1804.         && GET_CODE (insn) == JUMP_INSN
  1805.         && GET_CODE (body) == SET
  1806.         && SET_DEST (body) == pc_rtx
  1807.         && GET_CODE (SET_SRC (body)) == IF_THEN_ELSE
  1808.         /* This is done during prescan; it is not done again
  1809.            in final scan when prescan has been done.  */
  1810.         && prescan >= 0)
  1811.       {
  1812.         /* This function may alter the contents of its argument
  1813.            and clear some of the cc_status.flags bits.
  1814.            It may also return 1 meaning condition now always true
  1815.            or -1 meaning condition now always false
  1816.            or 2 meaning condition nontrivial but altered.  */
  1817.         register int result = alter_cond (XEXP (SET_SRC (body), 0));
  1818.         /* If condition now has fixed value, replace the IF_THEN_ELSE
  1819.            with its then-operand or its else-operand.  */
  1820.         if (result == 1)
  1821.           SET_SRC (body) = XEXP (SET_SRC (body), 1);
  1822.         if (result == -1)
  1823.           SET_SRC (body) = XEXP (SET_SRC (body), 2);
  1824.  
  1825.         /* The jump is now either unconditional or a no-op.
  1826.            If it has become a no-op, don't try to output it.
  1827.            (It would not be recognized.)  */
  1828.         if (SET_SRC (body) == pc_rtx)
  1829.           {
  1830.         PUT_CODE (insn, NOTE);
  1831.         NOTE_LINE_NUMBER (insn) = NOTE_INSN_DELETED;
  1832.         NOTE_SOURCE_FILE (insn) = 0;
  1833.         break;
  1834.           }
  1835.         else if (GET_CODE (SET_SRC (body)) == RETURN)
  1836.           /* Replace (set (pc) (return)) with (return).  */
  1837.           PATTERN (insn) = body = SET_SRC (body);
  1838.  
  1839.         /* Rerecognize the instruction if it has changed.  */
  1840.         if (result != 0)
  1841.           INSN_CODE (insn) = -1;
  1842.       }
  1843.  
  1844.     /* Make same adjustments to instructions that examine the
  1845.        condition codes without jumping (if this machine has them).  */
  1846.  
  1847.     if (cc_status.flags != 0
  1848.         && GET_CODE (body) == SET)
  1849.       {
  1850.         switch (GET_CODE (SET_SRC (body)))
  1851.           {
  1852.           case GTU:
  1853.           case GT:
  1854.           case LTU:
  1855.           case LT:
  1856.           case GEU:
  1857.           case GE:
  1858.           case LEU:
  1859.           case LE:
  1860.           case EQ:
  1861.           case NE:
  1862.         {
  1863.           register int result;
  1864.           if (XEXP (SET_SRC (body), 0) != cc0_rtx)
  1865.             break;
  1866.           result = alter_cond (SET_SRC (body));
  1867.           if (result == 1)
  1868.             validate_change (insn, &SET_SRC (body), const_true_rtx, 0);
  1869.           else if (result == -1)
  1870.             validate_change (insn, &SET_SRC (body), const0_rtx, 0);
  1871.           else if (result == 2)
  1872.             INSN_CODE (insn) = -1;
  1873.         }
  1874.           }
  1875.       }
  1876. #endif
  1877.  
  1878.     /* Do machine-specific peephole optimizations if desired.  */
  1879.  
  1880.     if (optimize && !flag_no_peephole && !nopeepholes)
  1881.       {
  1882.         rtx next = peephole (insn);
  1883.         /* When peepholing, if there were notes within the peephole,
  1884.            emit them before the peephole.  */
  1885.         if (next != 0 && next != NEXT_INSN (insn))
  1886.           {
  1887.         rtx prev = PREV_INSN (insn);
  1888.         rtx note;
  1889.  
  1890.         for (note = NEXT_INSN (insn); note != next;
  1891.              note = NEXT_INSN (note))
  1892.           final_scan_insn (note, file, optimize, prescan, nopeepholes);
  1893.  
  1894.         /* In case this is prescan, put the notes
  1895.            in proper position for later rescan.  */
  1896.         note = NEXT_INSN (insn);
  1897.         PREV_INSN (note) = prev;
  1898.         NEXT_INSN (prev) = note;
  1899.         NEXT_INSN (PREV_INSN (next)) = insn;
  1900.         PREV_INSN (insn) = PREV_INSN (next);
  1901.         NEXT_INSN (insn) = next;
  1902.         PREV_INSN (next) = insn;
  1903.           }
  1904.  
  1905.         /* PEEPHOLE might have changed this.  */
  1906.         body = PATTERN (insn);
  1907.       }
  1908.  
  1909.     /* Try to recognize the instruction.
  1910.        If successful, verify that the operands satisfy the
  1911.        constraints for the instruction.  Crash if they don't,
  1912.        since `reload' should have changed them so that they do.  */
  1913.  
  1914.     insn_code_number = recog_memoized (insn);
  1915.     insn_extract (insn);
  1916.     for (i = 0; i < insn_n_operands[insn_code_number]; i++)
  1917.       {
  1918.         if (GET_CODE (recog_operand[i]) == SUBREG)
  1919.           recog_operand[i] = alter_subreg (recog_operand[i]);
  1920.         else if (GET_CODE (recog_operand[i]) == PLUS
  1921.              || GET_CODE (recog_operand[i]) == MULT)
  1922.           recog_operand[i] = walk_alter_subreg (recog_operand[i]);
  1923.       }
  1924.  
  1925.     for (i = 0; i < insn_n_dups[insn_code_number]; i++)
  1926.       {
  1927.         if (GET_CODE (*recog_dup_loc[i]) == SUBREG)
  1928.           *recog_dup_loc[i] = alter_subreg (*recog_dup_loc[i]);
  1929.         else if (GET_CODE (*recog_dup_loc[i]) == PLUS
  1930.              || GET_CODE (*recog_dup_loc[i]) == MULT)
  1931.           *recog_dup_loc[i] = walk_alter_subreg (*recog_dup_loc[i]);
  1932.       }
  1933.  
  1934. #ifdef REGISTER_CONSTRAINTS
  1935.     if (! constrain_operands (insn_code_number, 1))
  1936.       fatal_insn_not_found (insn);
  1937. #endif
  1938.  
  1939.     /* Some target machines need to prescan each insn before
  1940.        it is output.  */
  1941.  
  1942. #ifdef FINAL_PRESCAN_INSN
  1943.     FINAL_PRESCAN_INSN (insn, recog_operand,
  1944.                 insn_n_operands[insn_code_number]);
  1945. #endif
  1946.  
  1947. #ifdef HAVE_cc0
  1948.     cc_prev_status = cc_status;
  1949.  
  1950.     /* Update `cc_status' for this instruction.
  1951.        The instruction's output routine may change it further.
  1952.        If the output routine for a jump insn needs to depend
  1953.        on the cc status, it should look at cc_prev_status.  */
  1954.  
  1955.     NOTICE_UPDATE_CC (body, insn);
  1956. #endif
  1957.  
  1958.     debug_insn = insn;
  1959.  
  1960.     /* If the proper template needs to be chosen by some C code,
  1961.        run that code and get the real template.  */
  1962.  
  1963.     template = insn_template[insn_code_number];
  1964.     if (template == 0)
  1965.       {
  1966.         template = (*insn_outfun[insn_code_number]) (recog_operand, insn);
  1967.  
  1968.         /* If the C code returns 0, it means that it is a jump insn
  1969.            which follows a deleted test insn, and that test insn
  1970.            needs to be reinserted.  */
  1971.         if (template == 0)
  1972.           {
  1973.         if (prev_nonnote_insn (insn) != last_ignored_compare)
  1974.           abort ();
  1975.         new_block = 0;
  1976.         return prev_nonnote_insn (insn);
  1977.           }
  1978.       }
  1979.  
  1980.     /* If the template is the string "#", it means that this insn must
  1981.        be split.  */
  1982.     if (template[0] == '#' && template[1] == '\0')
  1983.       {
  1984.         rtx new = try_split (body, insn, 0);
  1985.  
  1986.         /* If we didn't split the insn, go away.  */
  1987.         if (new == insn && PATTERN (new) == body)
  1988.           abort ();
  1989.           
  1990.         new_block = 0;
  1991.         return new;
  1992.       }
  1993.     
  1994.     if (prescan > 0)
  1995.       break;
  1996.  
  1997.     /* Output assembler code from the template.  */
  1998.  
  1999.     output_asm_insn (template, recog_operand);
  2000.  
  2001. #if 0
  2002.     /* It's not at all clear why we did this and doing so interferes
  2003.        with tests we'd like to do to use REG_WAS_0 notes, so let's try
  2004.        with this out.  */
  2005.  
  2006.     /* Mark this insn as having been output.  */
  2007.     INSN_DELETED_P (insn) = 1;
  2008. #endif
  2009.  
  2010.     debug_insn = 0;
  2011.       }
  2012.     }
  2013.   return NEXT_INSN (insn);
  2014. }
  2015.  
  2016. /* Output debugging info to the assembler file FILE
  2017.    based on the NOTE-insn INSN, assumed to be a line number.  */
  2018.  
  2019. static void
  2020. output_source_line (file, insn)
  2021.      FILE *file;
  2022.      rtx insn;
  2023. {
  2024.   register char *filename = NOTE_SOURCE_FILE (insn);
  2025.  
  2026.   /* Remember filename for basic block profiling.
  2027.      Filenames are allocated on the permanent obstack
  2028.      or are passed in ARGV, so we don't have to save
  2029.      the string.  */
  2030.  
  2031.   if (profile_block_flag && last_filename != filename)
  2032.     bb_file_label_num = add_bb_string (filename, TRUE);
  2033.  
  2034.   last_filename = filename;
  2035.   last_linenum = NOTE_LINE_NUMBER (insn);
  2036.   high_block_linenum = MAX (last_linenum, high_block_linenum);
  2037.   high_function_linenum = MAX (last_linenum, high_function_linenum);
  2038.  
  2039.   if (write_symbols != NO_DEBUG)
  2040.     {
  2041. /* Phil.B: 03-Oct-94 added q_anote from albaugh@agames.com (Mike Albaugh) */
  2042. #if defined(__amigados__) && defined(ASM_NOTE_SOURCE_LINE)
  2043.   ASM_NOTE_SOURCE_LINE(file,last_linenum,filename);
  2044. #endif
  2045. #ifdef SDB_DEBUGGING_INFO
  2046.       if (write_symbols == SDB_DEBUG
  2047. #if 0 /* People like having line numbers even in wrong file!  */
  2048.       /* COFF can't handle multiple source files--lose, lose.  */
  2049.       && !strcmp (filename, main_input_filename)
  2050. #endif
  2051.       /* COFF relative line numbers must be positive.  */
  2052.       && last_linenum > sdb_begin_function_line)
  2053.     {
  2054. #ifdef ASM_OUTPUT_SOURCE_LINE
  2055.       ASM_OUTPUT_SOURCE_LINE (file, last_linenum);
  2056. #else
  2057.       fprintf (file, "\t.ln\t%d\n",
  2058.            ((sdb_begin_function_line > -1)
  2059.             ? last_linenum - sdb_begin_function_line : 1));
  2060. #endif
  2061.     }
  2062. #endif
  2063.  
  2064. #if defined (DBX_DEBUGGING_INFO)
  2065.       if (write_symbols == DBX_DEBUG)
  2066.     dbxout_source_line (file, filename, NOTE_LINE_NUMBER (insn));
  2067. #endif
  2068.  
  2069. #if defined (XCOFF_DEBUGGING_INFO)
  2070.       if (write_symbols == XCOFF_DEBUG)
  2071.     xcoffout_source_line (file, filename, insn);
  2072. #endif
  2073.  
  2074. #ifdef DWARF_DEBUGGING_INFO
  2075.       if (write_symbols == DWARF_DEBUG)
  2076.     dwarfout_line (filename, NOTE_LINE_NUMBER (insn));
  2077. #endif
  2078.     }
  2079. }
  2080.  
  2081. /* If X is a SUBREG, replace it with a REG or a MEM,
  2082.    based on the thing it is a subreg of.  */
  2083.  
  2084. rtx
  2085. alter_subreg (x)
  2086.      register rtx x;
  2087. {
  2088.   register rtx y = SUBREG_REG (x);
  2089.   if (GET_CODE (y) == SUBREG)
  2090.     y = alter_subreg (y);
  2091.  
  2092.   if (GET_CODE (y) == REG)
  2093.     {
  2094.       /* If the containing reg really gets a hard reg, so do we.  */
  2095.       PUT_CODE (x, REG);
  2096.       REGNO (x) = REGNO (y) + SUBREG_WORD (x);
  2097.     }
  2098.   else if (GET_CODE (y) == MEM)
  2099.     {
  2100.       register int offset = SUBREG_WORD (x) * UNITS_PER_WORD;
  2101.       if (BYTES_BIG_ENDIAN)
  2102.     offset -= (MIN (UNITS_PER_WORD, GET_MODE_SIZE (GET_MODE (x)))
  2103.            - MIN (UNITS_PER_WORD, GET_MODE_SIZE (GET_MODE (y))));
  2104.       PUT_CODE (x, MEM);
  2105.       MEM_VOLATILE_P (x) = MEM_VOLATILE_P (y);
  2106.       XEXP (x, 0) = plus_constant (XEXP (y, 0), offset);
  2107.     }
  2108.  
  2109.   return x;
  2110. }
  2111.  
  2112. /* Do alter_subreg on all the SUBREGs contained in X.  */
  2113.  
  2114. static rtx
  2115. walk_alter_subreg (x)
  2116.      rtx x;
  2117. {
  2118.   switch (GET_CODE (x))
  2119.     {
  2120.     case PLUS:
  2121.     case MULT:
  2122.       XEXP (x, 0) = walk_alter_subreg (XEXP (x, 0));
  2123.       XEXP (x, 1) = walk_alter_subreg (XEXP (x, 1));
  2124.       break;
  2125.  
  2126.     case MEM:
  2127.       XEXP (x, 0) = walk_alter_subreg (XEXP (x, 0));
  2128.       break;
  2129.  
  2130.     case SUBREG:
  2131.       return alter_subreg (x);
  2132.     }
  2133.  
  2134.   return x;
  2135. }
  2136.  
  2137. #ifdef HAVE_cc0
  2138.  
  2139. /* Given BODY, the body of a jump instruction, alter the jump condition
  2140.    as required by the bits that are set in cc_status.flags.
  2141.    Not all of the bits there can be handled at this level in all cases.
  2142.  
  2143.    The value is normally 0.
  2144.    1 means that the condition has become always true.
  2145.    -1 means that the condition has become always false.
  2146.    2 means that COND has been altered.  */
  2147.  
  2148. static int
  2149. alter_cond (cond)
  2150.      register rtx cond;
  2151. {
  2152.   int value = 0;
  2153.  
  2154.   if (cc_status.flags & CC_REVERSED)
  2155.     {
  2156.       value = 2;
  2157.       PUT_CODE (cond, swap_condition (GET_CODE (cond)));
  2158.     }
  2159.  
  2160.   if (cc_status.flags & CC_INVERTED)
  2161.     {
  2162.       value = 2;
  2163.       PUT_CODE (cond, reverse_condition (GET_CODE (cond)));
  2164.     }
  2165.  
  2166.   if (cc_status.flags & CC_NOT_POSITIVE)
  2167.     switch (GET_CODE (cond))
  2168.       {
  2169.       case LE:
  2170.       case LEU:
  2171.       case GEU:
  2172.     /* Jump becomes unconditional.  */
  2173.     return 1;
  2174.  
  2175.       case GT:
  2176.       case GTU:
  2177.       case LTU:
  2178.     /* Jump becomes no-op.  */
  2179.     return -1;
  2180.  
  2181.       case GE:
  2182.     PUT_CODE (cond, EQ);
  2183.     value = 2;
  2184.     break;
  2185.  
  2186.       case LT:
  2187.     PUT_CODE (cond, NE);
  2188.     value = 2;
  2189.     break;
  2190.       }
  2191.  
  2192.   if (cc_status.flags & CC_NOT_NEGATIVE)
  2193.     switch (GET_CODE (cond))
  2194.       {
  2195.       case GE:
  2196.       case GEU:
  2197.     /* Jump becomes unconditional.  */
  2198.     return 1;
  2199.  
  2200.       case LT:
  2201.       case LTU:
  2202.     /* Jump becomes no-op.  */
  2203.     return -1;
  2204.  
  2205.       case LE:
  2206.       case LEU:
  2207.     PUT_CODE (cond, EQ);
  2208.     value = 2;
  2209.     break;
  2210.  
  2211.       case GT:
  2212.       case GTU:
  2213.     PUT_CODE (cond, NE);
  2214.     value = 2;
  2215.     break;
  2216.       }
  2217.  
  2218.   if (cc_status.flags & CC_NO_OVERFLOW)
  2219.     switch (GET_CODE (cond))
  2220.       {
  2221.       case GEU:
  2222.     /* Jump becomes unconditional.  */
  2223.     return 1;
  2224.  
  2225.       case LEU:
  2226.     PUT_CODE (cond, EQ);
  2227.     value = 2;
  2228.     break;
  2229.  
  2230.       case GTU:
  2231.     PUT_CODE (cond, NE);
  2232.     value = 2;
  2233.     break;
  2234.  
  2235.       case LTU:
  2236.     /* Jump becomes no-op.  */
  2237.     return -1;
  2238.       }
  2239.  
  2240.   if (cc_status.flags & (CC_Z_IN_NOT_N | CC_Z_IN_N))
  2241.     switch (GET_CODE (cond))
  2242.       {
  2243.       case LE:
  2244.       case LEU:
  2245.       case GE:
  2246.       case GEU:
  2247.       case LT:
  2248.       case LTU:
  2249.       case GT:
  2250.       case GTU:
  2251.     abort ();
  2252.  
  2253.       case NE:
  2254.     PUT_CODE (cond, cc_status.flags & CC_Z_IN_N ? GE : LT);
  2255.     value = 2;
  2256.     break;
  2257.  
  2258.       case EQ:
  2259.     PUT_CODE (cond, cc_status.flags & CC_Z_IN_N ? LT : GE);
  2260.     value = 2;
  2261.     break;
  2262.       }
  2263.  
  2264.   if (cc_status.flags & CC_NOT_SIGNED)
  2265.     /* The flags are valid if signed condition operators are converted
  2266.        to unsigned.  */
  2267.     switch (GET_CODE (cond))
  2268.       {
  2269.       case LE:
  2270.     PUT_CODE (cond, LEU);
  2271.     value = 2;
  2272.     break;
  2273.  
  2274.       case LT:
  2275.     PUT_CODE (cond, LTU);
  2276.     value = 2;
  2277.     break;
  2278.  
  2279.       case GT:
  2280.     PUT_CODE (cond, GTU);
  2281.     value = 2;
  2282.     break;
  2283.  
  2284.       case GE:
  2285.     PUT_CODE (cond, GEU);
  2286.     value = 2;
  2287.     break;
  2288.       }
  2289.  
  2290.   return value;
  2291. }
  2292. #endif
  2293.  
  2294. /* Report inconsistency between the assembler template and the operands.
  2295.    In an `asm', it's the user's fault; otherwise, the compiler's fault.  */
  2296.  
  2297. void
  2298. output_operand_lossage (str)
  2299.      char *str;
  2300. {
  2301.   if (this_is_asm_operands)
  2302.     error_for_asm (this_is_asm_operands, "invalid `asm': %s", str);
  2303.   else
  2304.     abort ();
  2305. }
  2306.  
  2307. /* Output of assembler code from a template, and its subroutines.  */
  2308.  
  2309. /* Output text from TEMPLATE to the assembler output file,
  2310.    obeying %-directions to substitute operands taken from
  2311.    the vector OPERANDS.
  2312.  
  2313.    %N (for N a digit) means print operand N in usual manner.
  2314.    %lN means require operand N to be a CODE_LABEL or LABEL_REF
  2315.       and print the label name with no punctuation.
  2316.    %cN means require operand N to be a constant
  2317.       and print the constant expression with no punctuation.
  2318.    %aN means expect operand N to be a memory address
  2319.       (not a memory reference!) and print a reference
  2320.       to that address.
  2321.    %nN means expect operand N to be a constant
  2322.       and print a constant expression for minus the value
  2323.       of the operand, with no other punctuation.  */
  2324.  
  2325. static void
  2326. output_asm_name ()
  2327. {
  2328.   if (flag_print_asm_name)
  2329.     {
  2330.       /* Annotate the assembly with a comment describing the pattern and
  2331.      alternative used.  */
  2332.       if (debug_insn)
  2333.     {
  2334.       register int num = INSN_CODE (debug_insn);
  2335.       fprintf (asm_out_file, " %s %d %s", 
  2336.            ASM_COMMENT_START, INSN_UID (debug_insn), insn_name[num]);
  2337.       if (insn_n_alternatives[num] > 1)
  2338.         fprintf (asm_out_file, "/%d", which_alternative + 1);
  2339.  
  2340.       /* Clear this so only the first assembler insn
  2341.          of any rtl insn will get the special comment for -dp.  */
  2342.       debug_insn = 0;
  2343.     }
  2344.     }
  2345. }
  2346.  
  2347. void
  2348. output_asm_insn (template, operands)
  2349.      char *template;
  2350.      rtx *operands;
  2351. {
  2352.   register char *p;
  2353.   register int c, i;
  2354.  
  2355.   /* An insn may return a null string template
  2356.      in a case where no assembler code is needed.  */
  2357.   if (*template == 0)
  2358.     return;
  2359.  
  2360.   p = template;
  2361.   putc ('\t', asm_out_file);
  2362.  
  2363. #ifdef ASM_OUTPUT_OPCODE
  2364.   ASM_OUTPUT_OPCODE (asm_out_file, p);
  2365. #endif
  2366.  
  2367.   while (c = *p++)
  2368.     switch (c)
  2369.       {
  2370.       case '\n':
  2371.     output_asm_name ();
  2372.     putc (c, asm_out_file);
  2373. #ifdef ASM_OUTPUT_OPCODE
  2374.     while ((c = *p) == '\t')
  2375.       {
  2376.         putc (c, asm_out_file);
  2377.         p++;
  2378.       }
  2379.     ASM_OUTPUT_OPCODE (asm_out_file, p);
  2380. #endif
  2381.     break;
  2382.  
  2383. #ifdef ASSEMBLER_DIALECT
  2384.       case '{':
  2385.     /* If we want the first dialect, do nothing.  Otherwise, skip
  2386.        DIALECT_NUMBER of strings ending with '|'.  */
  2387.     for (i = 0; i < dialect_number; i++)
  2388.       {
  2389.         while (*p && *p++ != '|')
  2390.           ;
  2391.  
  2392.         if (*p == '|')
  2393.           p++;
  2394.       }
  2395.     break;
  2396.  
  2397.       case '|':
  2398.     /* Skip to close brace.  */
  2399.     while (*p && *p++ != '}')
  2400.       ;
  2401.     break;
  2402.  
  2403.       case '}':
  2404.     break;
  2405. #endif
  2406.  
  2407.       case '%':
  2408.     /* %% outputs a single %.  */
  2409.     if (*p == '%')
  2410.       {
  2411.         p++;
  2412.         putc (c, asm_out_file);
  2413.       }
  2414.     /* %= outputs a number which is unique to each insn in the entire
  2415.        compilation.  This is useful for making local labels that are
  2416.        referred to more than once in a given insn.  */
  2417.     else if (*p == '=')
  2418.       {
  2419.         p++;
  2420.         fprintf (asm_out_file, "%d", insn_counter);
  2421.       }
  2422.     /* % followed by a letter and some digits
  2423.        outputs an operand in a special way depending on the letter.
  2424.        Letters `acln' are implemented directly.
  2425.        Other letters are passed to `output_operand' so that
  2426.        the PRINT_OPERAND macro can define them.  */
  2427.     else if ((*p >= 'a' && *p <= 'z')
  2428.          || (*p >= 'A' && *p <= 'Z'))
  2429.       {
  2430.         int letter = *p++;
  2431.         c = atoi (p);
  2432.  
  2433.         if (! (*p >= '0' && *p <= '9'))
  2434.           output_operand_lossage ("operand number missing after %-letter");
  2435.         else if (this_is_asm_operands && c >= (unsigned) insn_noperands)
  2436.           output_operand_lossage ("operand number out of range");
  2437.         else if (letter == 'l')
  2438.           output_asm_label (operands[c]);
  2439.         else if (letter == 'a')
  2440.           output_address (operands[c]);
  2441.         else if (letter == 'c')
  2442.           {
  2443.         if (CONSTANT_ADDRESS_P (operands[c]))
  2444.           output_addr_const (asm_out_file, operands[c]);
  2445.         else
  2446.           output_operand (operands[c], 'c');
  2447.           }
  2448.         else if (letter == 'n')
  2449.           {
  2450.         if (GET_CODE (operands[c]) == CONST_INT)
  2451.           fprintf (asm_out_file,
  2452. #if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT
  2453.                "%d",
  2454. #else
  2455.                "%ld",
  2456. #endif
  2457.                - INTVAL (operands[c]));
  2458.         else
  2459.           {
  2460.             putc ('-', asm_out_file);
  2461.             output_addr_const (asm_out_file, operands[c]);
  2462.           }
  2463.           }
  2464.         else
  2465.           output_operand (operands[c], letter);
  2466.         
  2467.         while ((c = *p) >= '0' && c <= '9') p++;
  2468.       }
  2469.     /* % followed by a digit outputs an operand the default way.  */
  2470.     else if (*p >= '0' && *p <= '9')
  2471.       {
  2472.         c = atoi (p);
  2473.         if (this_is_asm_operands && c >= (unsigned) insn_noperands)
  2474.           output_operand_lossage ("operand number out of range");
  2475.         else
  2476.           output_operand (operands[c], 0);
  2477.         while ((c = *p) >= '0' && c <= '9') p++;
  2478.       }
  2479.     /* % followed by punctuation: output something for that
  2480.        punctuation character alone, with no operand.
  2481.        The PRINT_OPERAND macro decides what is actually done.  */
  2482. #ifdef PRINT_OPERAND_PUNCT_VALID_P
  2483.     else if (PRINT_OPERAND_PUNCT_VALID_P (*p))
  2484.       output_operand (NULL_RTX, *p++);
  2485. #endif
  2486.     else
  2487.       output_operand_lossage ("invalid %%-code");
  2488.     break;
  2489.  
  2490.       default:
  2491.     putc (c, asm_out_file);
  2492.       }
  2493.  
  2494.   output_asm_name ();
  2495.  
  2496.   putc ('\n', asm_out_file);
  2497. }
  2498.  
  2499. /* Output a LABEL_REF, or a bare CODE_LABEL, as an assembler symbol.  */
  2500.  
  2501. void
  2502. output_asm_label (x)
  2503.      rtx x;
  2504. {
  2505.   char buf[256];
  2506.  
  2507.   if (GET_CODE (x) == LABEL_REF)
  2508.     ASM_GENERATE_INTERNAL_LABEL (buf, "L", CODE_LABEL_NUMBER (XEXP (x, 0)));
  2509.   else if (GET_CODE (x) == CODE_LABEL)
  2510.     ASM_GENERATE_INTERNAL_LABEL (buf, "L", CODE_LABEL_NUMBER (x));
  2511.   else
  2512.     output_operand_lossage ("`%l' operand isn't a label");
  2513.  
  2514.   assemble_name (asm_out_file, buf);
  2515. }
  2516.  
  2517. /* Print operand X using machine-dependent assembler syntax.
  2518.    The macro PRINT_OPERAND is defined just to control this function.
  2519.    CODE is a non-digit that preceded the operand-number in the % spec,
  2520.    such as 'z' if the spec was `%z3'.  CODE is 0 if there was no char
  2521.    between the % and the digits.
  2522.    When CODE is a non-letter, X is 0.
  2523.  
  2524.    The meanings of the letters are machine-dependent and controlled
  2525.    by PRINT_OPERAND.  */
  2526.  
  2527. static void
  2528. output_operand (x, code)
  2529.      rtx x;
  2530.      int code;
  2531. {
  2532.   if (x && GET_CODE (x) == SUBREG)
  2533.     x = alter_subreg (x);
  2534.  
  2535.   /* If X is a pseudo-register, abort now rather than writing trash to the
  2536.      assembler file.  */
  2537.  
  2538.   if (x && GET_CODE (x) == REG && REGNO (x) >= FIRST_PSEUDO_REGISTER)
  2539.     abort ();
  2540.  
  2541.   PRINT_OPERAND (asm_out_file, x, code);
  2542. }
  2543.  
  2544. /* Print a memory reference operand for address X
  2545.    using machine-dependent assembler syntax.
  2546.    The macro PRINT_OPERAND_ADDRESS exists just to control this function.  */
  2547.  
  2548. void
  2549. output_address (x)
  2550.      rtx x;
  2551. {
  2552.   walk_alter_subreg (x);
  2553.   PRINT_OPERAND_ADDRESS (asm_out_file, x);
  2554. }
  2555.  
  2556. /* Print an integer constant expression in assembler syntax.
  2557.    Addition and subtraction are the only arithmetic
  2558.    that may appear in these expressions.  */
  2559.  
  2560. void
  2561. output_addr_const (file, x)
  2562.      FILE *file;
  2563.      rtx x;
  2564. {
  2565.   char buf[256];
  2566.  
  2567.  restart:
  2568.   switch (GET_CODE (x))
  2569.     {
  2570.     case PC:
  2571.       if (flag_pic)
  2572.     putc ('.', file);
  2573.       else
  2574.     abort ();
  2575.       break;
  2576.  
  2577.     case SYMBOL_REF:
  2578.       assemble_name (file, XSTR (x, 0));
  2579.       break;
  2580.  
  2581.     case LABEL_REF:
  2582.       ASM_GENERATE_INTERNAL_LABEL (buf, "L", CODE_LABEL_NUMBER (XEXP (x, 0)));
  2583.       assemble_name (file, buf);
  2584.       break;
  2585.  
  2586.     case CODE_LABEL:
  2587.       ASM_GENERATE_INTERNAL_LABEL (buf, "L", CODE_LABEL_NUMBER (x));
  2588.       assemble_name (file, buf);
  2589.       break;
  2590.  
  2591.     case CONST_INT:
  2592.       fprintf (file,
  2593. #if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT
  2594.            "%d",
  2595. #else
  2596.            "%ld",
  2597. #endif
  2598.            INTVAL (x));
  2599.       break;
  2600.  
  2601.     case CONST:
  2602.       /* This used to output parentheses around the expression,
  2603.      but that does not work on the 386 (either ATT or BSD assembler).  */
  2604.       output_addr_const (file, XEXP (x, 0));
  2605.       break;
  2606.  
  2607.     case CONST_DOUBLE:
  2608.       if (GET_MODE (x) == VOIDmode)
  2609.     {
  2610.       /* We can use %d if the number is one word and positive.  */
  2611.       if (CONST_DOUBLE_HIGH (x))
  2612.         fprintf (file,
  2613. #if HOST_BITS_PER_WIDE_INT == 64
  2614. #if HOST_BITS_PER_WIDE_INT != HOST_BITS_PER_INT
  2615.              "0x%lx%016lx",
  2616. #else
  2617.              "0x%x%016x",
  2618. #endif
  2619. #else
  2620. #if HOST_BITS_PER_WIDE_INT != HOST_BITS_PER_INT
  2621.              "0x%lx%08lx",
  2622. #else
  2623.              "0x%x%08x",
  2624. #endif
  2625. #endif
  2626.              CONST_DOUBLE_HIGH (x), CONST_DOUBLE_LOW (x));
  2627.       else if  (CONST_DOUBLE_LOW (x) < 0)
  2628.         fprintf (file,
  2629. #if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT
  2630.              "0x%x",
  2631. #else
  2632.              "0x%lx",
  2633. #endif
  2634.              CONST_DOUBLE_LOW (x));
  2635.       else
  2636.         fprintf (file,
  2637. #if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT
  2638.              "%d",
  2639. #else
  2640.              "%ld",
  2641. #endif
  2642.              CONST_DOUBLE_LOW (x));
  2643.     }
  2644.       else
  2645.     /* We can't handle floating point constants;
  2646.        PRINT_OPERAND must handle them.  */
  2647.     output_operand_lossage ("floating constant misused");
  2648.       break;
  2649.  
  2650.     case PLUS:
  2651.       /* Some assemblers need integer constants to appear last (eg masm).  */
  2652.       if (GET_CODE (XEXP (x, 0)) == CONST_INT)
  2653.     {
  2654.       output_addr_const (file, XEXP (x, 1));
  2655.       if (INTVAL (XEXP (x, 0)) >= 0)
  2656.         fprintf (file, "+");
  2657.       output_addr_const (file, XEXP (x, 0));
  2658.     }
  2659.       else
  2660.     {
  2661.       output_addr_const (file, XEXP (x, 0));
  2662.       if (INTVAL (XEXP (x, 1)) >= 0)
  2663.         fprintf (file, "+");
  2664.       output_addr_const (file, XEXP (x, 1));
  2665.     }
  2666.       break;
  2667.  
  2668.     case MINUS:
  2669.       /* Avoid outputting things like x-x or x+5-x,
  2670.      since some assemblers can't handle that.  */
  2671.       x = simplify_subtraction (x);
  2672.       if (GET_CODE (x) != MINUS)
  2673.     goto restart;
  2674.  
  2675.       output_addr_const (file, XEXP (x, 0));
  2676.       fprintf (file, "-");
  2677.       if (GET_CODE (XEXP (x, 1)) == CONST_INT
  2678.       && INTVAL (XEXP (x, 1)) < 0)
  2679.     {
  2680.       fprintf (file, ASM_OPEN_PAREN);
  2681.       output_addr_const (file, XEXP (x, 1));
  2682.       fprintf (file, ASM_CLOSE_PAREN);
  2683.     }
  2684.       else
  2685.     output_addr_const (file, XEXP (x, 1));
  2686.       break;
  2687.  
  2688.     case ZERO_EXTEND:
  2689.     case SIGN_EXTEND:
  2690.       output_addr_const (file, XEXP (x, 0));
  2691.       break;
  2692.  
  2693.     default:
  2694.       output_operand_lossage ("invalid expression as operand");
  2695.     }
  2696. }
  2697.  
  2698. /* A poor man's fprintf, with the added features of %I, %R, %L, and %U.
  2699.    %R prints the value of REGISTER_PREFIX.
  2700.    %L prints the value of LOCAL_LABEL_PREFIX.
  2701.    %U prints the value of USER_LABEL_PREFIX.
  2702.    %I prints the value of IMMEDIATE_PREFIX.
  2703.    %O runs ASM_OUTPUT_OPCODE to transform what follows in the string.
  2704.    Also supported are %d, %x, %s, %e, %f, %g and %%.
  2705.  
  2706.    We handle alternate assembler dialects here, just like output_asm_insn.  */
  2707.  
  2708. void
  2709. asm_fprintf VPROTO((FILE *file, char *p, ...))
  2710. {
  2711. #ifndef __STDC__
  2712.   FILE *file;
  2713.   char *p;
  2714. #endif
  2715.   va_list argptr;
  2716.   char buf[10];
  2717.   char *q, c;
  2718.   int i;
  2719.  
  2720.   VA_START (argptr, p);
  2721.  
  2722. #ifndef __STDC__
  2723.   file = va_arg (argptr, FILE*);
  2724.   p = va_arg (argptr, char*);
  2725. #endif
  2726.  
  2727.   buf[0] = '%';
  2728.  
  2729.   while (c = *p++)
  2730.     switch (c)
  2731.       {
  2732. #ifdef ASSEMBLER_DIALECT
  2733.       case '{':
  2734.     /* If we want the first dialect, do nothing.  Otherwise, skip
  2735.        DIALECT_NUMBER of strings ending with '|'.  */
  2736.     for (i = 0; i < dialect_number; i++)
  2737.       {
  2738.         while (*p && *p++ != '|')
  2739.           ;
  2740.  
  2741.         if (*p == '|')
  2742.           p++;
  2743.       }
  2744.     break;
  2745.  
  2746.       case '|':
  2747.     /* Skip to close brace.  */
  2748.     while (*p && *p++ != '}')
  2749.       ;
  2750.     break;
  2751.  
  2752.       case '}':
  2753.     break;
  2754. #endif
  2755.  
  2756.       case '%':
  2757.     c = *p++;
  2758.     q = &buf[1];
  2759.     while ((c >= '0' && c <= '9') || c == '.')
  2760.       {
  2761.         *q++ = c;
  2762.         c = *p++;
  2763.       }
  2764.     switch (c)
  2765.       {
  2766.       case '%':
  2767.         fprintf (file, "%%");
  2768.         break;
  2769.  
  2770.       case 'd':  case 'i':  case 'u':
  2771.       case 'x':  case 'p':  case 'X':
  2772.       case 'o':
  2773.         *q++ = c;
  2774.         *q = 0;
  2775.         fprintf (file, buf, va_arg (argptr, int));
  2776.         break;
  2777.  
  2778.       case 'w':
  2779.         /* This is a prefix to the 'd', 'i', 'u', 'x', 'p', and 'X' cases,
  2780.            but we do not check for those cases.  It means that the value
  2781.            is a HOST_WIDE_INT, which may be either `int' or `long'.  */
  2782.  
  2783. #if HOST_BITS_PER_WIDE_INT != HOST_BITS_PER_INT
  2784.         *q++ = 'l';
  2785. #endif
  2786.  
  2787.         *q++ = *p++;
  2788.         *q = 0;
  2789.         fprintf (file, buf, va_arg (argptr, HOST_WIDE_INT));
  2790.         break;
  2791.  
  2792.       case 'l':
  2793.         *q++ = c;
  2794.         *q++ = *p++;
  2795.         *q = 0;
  2796.         fprintf (file, buf, va_arg (argptr, long));
  2797.         break;
  2798.  
  2799.       case 'e':
  2800.       case 'f':
  2801.       case 'g':
  2802.         *q++ = c;
  2803.         *q = 0;
  2804.         fprintf (file, buf, va_arg (argptr, double));
  2805.         break;
  2806.  
  2807.       case 's':
  2808.         *q++ = c;
  2809.         *q = 0;
  2810.         fprintf (file, buf, va_arg (argptr, char *));
  2811.         break;
  2812.  
  2813.       case 'O':
  2814. #ifdef ASM_OUTPUT_OPCODE
  2815.         ASM_OUTPUT_OPCODE (asm_out_file, p);
  2816. #endif
  2817.         break;
  2818.  
  2819.       case 'R':
  2820. #ifdef REGISTER_PREFIX
  2821.         fprintf (file, "%s", REGISTER_PREFIX);
  2822. #endif
  2823.         break;
  2824.  
  2825.       case 'I':
  2826. #ifdef IMMEDIATE_PREFIX
  2827.         fprintf (file, "%s", IMMEDIATE_PREFIX);
  2828. #endif
  2829.         break;
  2830.  
  2831.       case 'L':
  2832. #ifdef LOCAL_LABEL_PREFIX
  2833.         fprintf (file, "%s", LOCAL_LABEL_PREFIX);
  2834. #endif
  2835.         break;
  2836.  
  2837.       case 'U':
  2838. #ifdef USER_LABEL_PREFIX
  2839.         fprintf (file, "%s", USER_LABEL_PREFIX);
  2840. #endif
  2841.         break;
  2842.  
  2843.       default:
  2844.         abort ();
  2845.       }
  2846.     break;
  2847.  
  2848.       default:
  2849.     fputc (c, file);
  2850.       }
  2851. }
  2852.  
  2853. /* Split up a CONST_DOUBLE or integer constant rtx
  2854.    into two rtx's for single words,
  2855.    storing in *FIRST the word that comes first in memory in the target
  2856.    and in *SECOND the other.  */
  2857.  
  2858. void
  2859. split_double (value, first, second)
  2860.      rtx value;
  2861.      rtx *first, *second;
  2862. {
  2863.   if (GET_CODE (value) == CONST_INT)
  2864.     {
  2865.       if (HOST_BITS_PER_WIDE_INT >= (2 * BITS_PER_WORD))
  2866.     {
  2867.       /* In this case the CONST_INT holds both target words.
  2868.          Extract the bits from it into two word-sized pieces.  */
  2869.       rtx low, high;
  2870.       HOST_WIDE_INT word_mask;
  2871.       /* Avoid warnings for shift count >= BITS_PER_WORD.  */
  2872.       int shift_count = BITS_PER_WORD - 1;
  2873.  
  2874.       word_mask = (HOST_WIDE_INT) 1 << shift_count;
  2875.       word_mask |= word_mask - 1;
  2876.       low = GEN_INT (INTVAL (value) & word_mask);
  2877.       high = GEN_INT ((INTVAL (value) >> (shift_count + 1)) & word_mask);
  2878.       if (WORDS_BIG_ENDIAN)
  2879.         {
  2880.           *first = high;
  2881.           *second = low;
  2882.         }
  2883.       else
  2884.         {
  2885.           *first = low;
  2886.           *second = high;
  2887.         }
  2888.     }
  2889.       else
  2890.     {
  2891.       /* The rule for using CONST_INT for a wider mode
  2892.          is that we regard the value as signed.
  2893.          So sign-extend it.  */
  2894.       rtx high = (INTVAL (value) < 0 ? constm1_rtx : const0_rtx);
  2895.       if (WORDS_BIG_ENDIAN)
  2896.         {
  2897.           *first = high;
  2898.           *second = value;
  2899.         }
  2900.       else
  2901.         {
  2902.           *first = value;
  2903.           *second = high;
  2904.         }
  2905.     }
  2906.     }
  2907.   else if (GET_CODE (value) != CONST_DOUBLE)
  2908.     {
  2909.       if (WORDS_BIG_ENDIAN)
  2910.     {
  2911.       *first = const0_rtx;
  2912.       *second = value;
  2913.     }
  2914.       else
  2915.     {
  2916.       *first = value;
  2917.       *second = const0_rtx;
  2918.     }
  2919.     }
  2920.   else if (GET_MODE (value) == VOIDmode
  2921.        /* This is the old way we did CONST_DOUBLE integers.  */
  2922.        || GET_MODE_CLASS (GET_MODE (value)) == MODE_INT)
  2923.     {
  2924.       /* In an integer, the words are defined as most and least significant.
  2925.      So order them by the target's convention.  */
  2926.       if (WORDS_BIG_ENDIAN)
  2927.     {
  2928.       *first = GEN_INT (CONST_DOUBLE_HIGH (value));
  2929.       *second = GEN_INT (CONST_DOUBLE_LOW (value));
  2930.     }
  2931.       else
  2932.     {
  2933.       *first = GEN_INT (CONST_DOUBLE_LOW (value));
  2934.       *second = GEN_INT (CONST_DOUBLE_HIGH (value));
  2935.     }
  2936.     }
  2937.   else
  2938.     {
  2939. #ifdef REAL_ARITHMETIC
  2940.       REAL_VALUE_TYPE r; long l[2];
  2941.       REAL_VALUE_FROM_CONST_DOUBLE (r, value);
  2942.  
  2943.       /* Note, this converts the REAL_VALUE_TYPE to the target's
  2944.      format, splits up the floating point double and outputs
  2945.      exactly 32 bits of it into each of l[0] and l[1] --
  2946.      not necessarily BITS_PER_WORD bits. */
  2947.       REAL_VALUE_TO_TARGET_DOUBLE (r, l);
  2948.  
  2949.       *first = GEN_INT ((HOST_WIDE_INT) l[0]);
  2950.       *second = GEN_INT ((HOST_WIDE_INT) l[1]);
  2951. #else
  2952.       if ((HOST_FLOAT_FORMAT != TARGET_FLOAT_FORMAT
  2953.        || HOST_BITS_PER_WIDE_INT != BITS_PER_WORD)
  2954.       && ! flag_pretend_float)
  2955.       abort ();
  2956.  
  2957.       if (
  2958. #ifdef HOST_WORDS_BIG_ENDIAN
  2959.       WORDS_BIG_ENDIAN
  2960. #else
  2961.       ! WORDS_BIG_ENDIAN
  2962. #endif
  2963.       )
  2964.     {
  2965.       /* Host and target agree => no need to swap.  */
  2966.       *first = GEN_INT (CONST_DOUBLE_LOW (value));
  2967.       *second = GEN_INT (CONST_DOUBLE_HIGH (value));
  2968.     }
  2969.       else
  2970.     {
  2971.       *second = GEN_INT (CONST_DOUBLE_LOW (value));
  2972.       *first = GEN_INT (CONST_DOUBLE_HIGH (value));
  2973.     }
  2974. #endif /* no REAL_ARITHMETIC */
  2975.     }
  2976. }
  2977.  
  2978. /* Return nonzero if this function has no function calls.  */
  2979.  
  2980. int
  2981. leaf_function_p ()
  2982. {
  2983.   rtx insn;
  2984.  
  2985.   if (profile_flag || profile_block_flag)
  2986.     return 0;
  2987.  
  2988.   for (insn = get_insns (); insn; insn = NEXT_INSN (insn))
  2989.     {
  2990.       if (GET_CODE (insn) == CALL_INSN)
  2991.     return 0;
  2992.       if (GET_CODE (insn) == INSN
  2993.       && GET_CODE (PATTERN (insn)) == SEQUENCE
  2994.       && GET_CODE (XVECEXP (PATTERN (insn), 0, 0)) == CALL_INSN)
  2995.     return 0;
  2996.     }
  2997.   for (insn = current_function_epilogue_delay_list; insn; insn = XEXP (insn, 1))
  2998.     {
  2999.       if (GET_CODE (XEXP (insn, 0)) == CALL_INSN)
  3000.     return 0;
  3001.       if (GET_CODE (XEXP (insn, 0)) == INSN
  3002.       && GET_CODE (PATTERN (XEXP (insn, 0))) == SEQUENCE
  3003.       && GET_CODE (XVECEXP (PATTERN (XEXP (insn, 0)), 0, 0)) == CALL_INSN)
  3004.     return 0;
  3005.     }
  3006.  
  3007.   return 1;
  3008. }
  3009.  
  3010. /* On some machines, a function with no call insns
  3011.    can run faster if it doesn't create its own register window.
  3012.    When output, the leaf function should use only the "output"
  3013.    registers.  Ordinarily, the function would be compiled to use
  3014.    the "input" registers to find its arguments; it is a candidate
  3015.    for leaf treatment if it uses only the "input" registers.
  3016.    Leaf function treatment means renumbering so the function
  3017.    uses the "output" registers instead.  */
  3018.  
  3019. #ifdef LEAF_REGISTERS
  3020.  
  3021. static char permitted_reg_in_leaf_functions[] = LEAF_REGISTERS;
  3022.  
  3023. /* Return 1 if this function uses only the registers that can be
  3024.    safely renumbered.  */
  3025.  
  3026. int
  3027. only_leaf_regs_used ()
  3028. {
  3029.   int i;
  3030.  
  3031.   for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
  3032.     {
  3033.       if ((regs_ever_live[i] || global_regs[i])
  3034.       && ! permitted_reg_in_leaf_functions[i])
  3035.     return 0;
  3036.     }
  3037.   return 1;
  3038. }
  3039.  
  3040. /* Scan all instructions and renumber all registers into those
  3041.    available in leaf functions.  */
  3042.  
  3043. static void
  3044. leaf_renumber_regs (first)
  3045.      rtx first;
  3046. {
  3047.   rtx insn;
  3048.  
  3049.   /* Renumber only the actual patterns.
  3050.      The reg-notes can contain frame pointer refs,
  3051.      and renumbering them could crash, and should not be needed.  */
  3052.   for (insn = first; insn; insn = NEXT_INSN (insn))
  3053.     if (GET_RTX_CLASS (GET_CODE (insn)) == 'i')
  3054.       leaf_renumber_regs_insn (PATTERN (insn));
  3055.   for (insn = current_function_epilogue_delay_list; insn; insn = XEXP (insn, 1))
  3056.     if (GET_RTX_CLASS (GET_CODE (XEXP (insn, 0))) == 'i')
  3057.       leaf_renumber_regs_insn (PATTERN (XEXP (insn, 0)));
  3058. }
  3059.  
  3060. /* Scan IN_RTX and its subexpressions, and renumber all regs into those
  3061.    available in leaf functions.  */
  3062.  
  3063. void
  3064. leaf_renumber_regs_insn (in_rtx)
  3065.      register rtx in_rtx;
  3066. {
  3067.   register int i, j;
  3068.   register char *format_ptr;
  3069.  
  3070.   if (in_rtx == 0)
  3071.     return;
  3072.  
  3073.   /* Renumber all input-registers into output-registers.
  3074.      renumbered_regs would be 1 for an output-register;
  3075.      they  */
  3076.  
  3077.   if (GET_CODE (in_rtx) == REG)
  3078.     {
  3079.       int newreg;
  3080.  
  3081.       /* Don't renumber the same reg twice.  */
  3082.       if (in_rtx->used)
  3083.     return;
  3084.  
  3085.       newreg = REGNO (in_rtx);
  3086.       /* Don't try to renumber pseudo regs.  It is possible for a pseudo reg
  3087.      to reach here as part of a REG_NOTE.  */
  3088.       if (newreg >= FIRST_PSEUDO_REGISTER)
  3089.     {
  3090.       in_rtx->used = 1;
  3091.       return;
  3092.     }
  3093.       newreg = LEAF_REG_REMAP (newreg);
  3094.       if (newreg < 0)
  3095.     abort ();
  3096.       regs_ever_live[REGNO (in_rtx)] = 0;
  3097.       regs_ever_live[newreg] = 1;
  3098.       REGNO (in_rtx) = newreg;
  3099.       in_rtx->used = 1;
  3100.     }
  3101.  
  3102.   if (GET_RTX_CLASS (GET_CODE (in_rtx)) == 'i')
  3103.     {
  3104.       /* Inside a SEQUENCE, we find insns.
  3105.      Renumber just the patterns of these insns,
  3106.      just as we do for the top-level insns.  */
  3107.       leaf_renumber_regs_insn (PATTERN (in_rtx));
  3108.       return;
  3109.     }
  3110.  
  3111.   format_ptr = GET_RTX_FORMAT (GET_CODE (in_rtx));
  3112.  
  3113.   for (i = 0; i < GET_RTX_LENGTH (GET_CODE (in_rtx)); i++)
  3114.     switch (*format_ptr++)
  3115.       {
  3116.       case 'e':
  3117.     leaf_renumber_regs_insn (XEXP (in_rtx, i));
  3118.     break;
  3119.  
  3120.       case 'E':
  3121.     if (NULL != XVEC (in_rtx, i))
  3122.       {
  3123.         for (j = 0; j < XVECLEN (in_rtx, i); j++)
  3124.           leaf_renumber_regs_insn (XVECEXP (in_rtx, i, j));
  3125.       }
  3126.     break;
  3127.  
  3128.       case 'S':
  3129.       case 's':
  3130.       case '0':
  3131.       case 'i':
  3132.       case 'w':
  3133.       case 'n':
  3134.       case 'u':
  3135.     break;
  3136.  
  3137.       default:
  3138.     abort ();
  3139.       }
  3140. }
  3141. #endif
  3142.